CodTango
CodTango

Reputation: 355

How can I query multiple components in Ext?

In my app, I have two pagingtoolbar in two views (separate files), how can I query them both in the controller?

dockedItems: [{
    xtype: 'pagingtoolbar',
    store: 'User',
    dock: 'bottom',
    displayInfo: true
}]

bbar: {
    xtype: 'pagingtoolbar',
    store: this.store,
    displayInfo: true
}

Upvotes: 2

Views: 235

Answers (2)

Guilherme Lopes
Guilherme Lopes

Reputation: 4760

Just adding to Alex Tokarev's answer, if you want to select them at run time, lets say, when you click on a button, you can use:

 ...
 handler : function () {
      var mytoolbars = Ext.ComponentQuery.query('pagingtoolbar'); // will assign all available toolbars to your mytoolbars array.
 }
 ....

Upvotes: 1

Alex Tokarev
Alex Tokarev

Reputation: 4861

Controllers use ComponentQuery and their selectors are global, so just xtype should work:

Ext.define('MyController', {
    extend: 'Ext.app.Controller',

    init: function() {
        this.control({
            pagingtoolbar: {
                ...
            }
        });
    }
});

Upvotes: 1

Related Questions