tags:

views:

388

answers:

2

Hi, Inside my extjs FormPanel, i have several editor grids. I don't know what the Id's of these grids are, so i cant use Ext.getCmp. so what is the best way to say 'Get all the 'editorgrid' types that are in this FormPanel'?

Thanks so much.

A: 

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);
Ates Goral
perfect works. thanks!
29er
A: 

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

... });

Upper Stage