Thanks, marxan - that makes things clearer. So one option would be to use closures in a way similar to what I suggested before, this would look like:
Code:
init: function() {
this.control({
'TaxSSC': {
afterrender: function(grid) {
this.setUpdate(grid, 'updateDateTaxSsc');
}
},
'MetrSeries': {
afterrender: function(grid) {
this.setUpdate(grid, 'updateDateTraps');
}
}
});
},
setUpdate: function(grid, labelId) {
grid.dockedItems.getAt(1).items.getByKey(labelId).setText('Last update: ' + Global.lastUpdate[Global.indicatorGroup]);
// ...
}
Otherwise, you could switch the order of the arguments for the setUpdate method and use the Ext.pass function which creates a closure for you under-the-hood:
Code:
init: function() {
this.control({
'TaxSSC': {
afterrender: Ext.pass(this.setUpdate, ['updateDateTaxSsc'])
},
'MetrSeries': {
afterrender: Ext.pass(this.setUpdate, ['updateDateTraps'])
}
});
},
setUpdate: function(labelId, grid) {
grid.dockedItems.getAt(1).items.getByKey(labelId).setText('Last update: ' + Global.lastUpdate[Global.indicatorGroup]);
// ...
}
Switching the argument order in this case is necessary here because Ext.pass inserts the extra arguments before the "natural" arguments of the function.