Reputation: 4432
How does controllers in ExtJs handle the events as shown below? If all button clicks go through the controller will it slow it down a lot?
Ext.define('App.controller.MyResults', {
extend : 'Ext.app.Controller',
stores : ['Store1', 'Store2'],
models : ['MyModel'],
views : ['myResults.Grid']
},
init: function() {
this.control({
'button': {
click: this.refreshGrid
}
});
}
);
Upvotes: 0
Views: 1618
Reputation: 4861
Yes it will, and that is why the component selectors should be as specific as possible. In your case, assuming that myResults.Grid
is defined as:
Ext.define('myResults.Grid', {
extend: 'Ext.grid.Panel', // Not necessarily this class
alias: 'widget.myresultsgrid', // xtype === 'myresultsgrid'
...
});
You can define your Controller as:
Ext.define('App.controller.MyResults', {
extend: 'Ext.app.Controller',
...
init: function() {
this.control({
'myresultsgrid button': {
click: this.refreshGrid
}
});
}
});
This will ensure that your Controller will see click
events only from buttons in MyResults grid.
Upvotes: 3