开发者

Getting child editorGrid types in a FormPanel

开发者 https://www.devze.com 2022-12-10 23:28 出处:网络
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.

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',

... });

0

精彩评论

暂无评论...
验证码 换一张
取 消