Oliver Watkins
Oliver Watkins

Reputation: 13539

Trying to get reference to ExtJS Grid from toolbar

I have a Grid..

And I have a toolbar..

Ext.define('js.grid.PackageGrid', {

    extend: 'Ext.grid.Panel',

    tbar: [{
         GridUtils.getSearchTextField(myGridReferenceHere)
    }]

}

I need to get a reference to the defining Grid. I am not sure this is possible. Is it possible?

EDIT FROM ORIGINAL POSTER:

I ended up doing it like this: The text field is defined in the grid, and only the search action is delegated to another method.

tbar: [{

        xtype: 'textfield', enableKeyEvents: true, listeners: {
            keyup: function (string) {

                var grid = this.up();

                gridUtils.getSearchAction(tablestore, string, grid)
            }
        }

}]

Upvotes: 0

Views: 1134

Answers (2)

Saki
Saki

Reputation: 5856

It is not possible during the define time. You execute the above method at the time when neither grid nor toolbar exists. You can get the reference during initComponent execution of either grid or toolbar but not at the define time.

For more info see:

Upvotes: 1

Elias Medeiros
Elias Medeiros

Reputation: 395

Try this:

tbar: [{
     GridUtils.getSearchTextField(this.up())
}]

http://docs-devel.sencha.com/extjs/4.2.1/#!/api/Ext.toolbar.Toolbar-method-up

Upvotes: 0

Related Questions