2009-11-11 52 views
1

在我的extjs FormPanel中,我有幾個編輯器網格。我不知道這些網格的ID是什麼,所以我不能使用Ext.getCmp在FormPanel中獲取子editorGrid類型

什麼是最好的方式來說'獲取所有editorgrid類型在這FormPanel'?

回答

1

您可以通過每個項目的類型,通過使用isXType過濾items收集FormPanel中的:

var grids = formPanel.items.filterBy(function (item) { 
    return item.isXType("editorgrid"); 
}); 

grids將所有EditorGridPanel項目的新的集合。

更新:一個更簡潔的方式:

var grids = formPanel.findByType("editorgrid", true); 
+0

完美的作品。謝謝! – 29er 2009-11-12 04:57:17

0

雖然我們避免硬編碼DOM的ID,其可用都能得心應手組件ID。

... });

this.gridTwoId = Ext.id(null, 'gridTwo'); // guaranteed unique 
new Ext.grid.GridPanel({ 
     id: this.gridTwoId, 
     store: storeTwo, 
     columns: columnsTwo, 
     title: 'Grid Two', 

... });