Getting child editorGrid types in a FormPanel
Inside my extjs FormPanel
, I have several editor grids. I don't know what the ID开发者_JAVA技巧s of these grids are, so I can't use Ext.getCmp
.
What is the best way to say 'Get all the editorgrid
types that are in this FormPanel
'?
You could filter the items
collection of the FormPanel by the type of each item by using isXType
:
var grids = formPanel.items.filterBy(function (item) {
return item.isXType("editorgrid");
});
grids
will be a new collection of all the EditorGridPanel
items.
Update: A more concise way:
var grids = formPanel.findByType("editorgrid", true);
Though we avoid hardcoding DOM IDs, having component IDs available can be handy.
this.gridOneId = Ext.id( null, 'gridOne' ); // guaranteed unique
new Ext.grid.GridPanel({
id: this.gridOneId,
store: storeOne,
columns: columnsOne,
title: 'Grid One',
... });
this.gridTwoId = Ext.id( null, 'gridTwo' ); // guaranteed unique
new Ext.grid.GridPanel({
id: this.gridTwoId,
store: storeTwo,
columns: columnsTwo,
title: 'Grid Two',
... });
精彩评论