I have a view - a panel basically ... i have menu buttons in it ..... 4 menus inside a button ... i want to call one particular function present in the controller each time but with different parameters ... how is it possible ?
xtype: 'button',
menu: {
items: [{
text : 'menu 1',
listeners: {
click: 'controllerfunction' //with argument 1
}
}, {
text : 'menu 2',
listeners: {
click: 'controllerfunction' // with argument 2
}
}]
}
Alexander's way works, but there is another way that is more in the same style you were using.
xtype: 'button',
menu: {
items: [{
text : 'menu 1',
listeners: {
click: {fn: 'controllerfunction', extraArg: 'yes'}}
}
}, {
text : 'menu 2',
listeners: {
click: {fn: 'controllerfunction', extraArg: 'no'}}
}
}]
}
// In your controller
controllerFunction: function(event, target,options) {
if (options.extraArg === 'yes') {
}
}
See https://fiddle.sencha.com/#fiddle/15c7
I use the following:
xtype: 'button',
xtypeToOpen:'listView', // This is the argument.
id: 'btnListView',
text: 'List'
and
xtype: 'button',
xtypeToOpen:'gridView', // This is the argument.
id: 'btnGridView',
text: 'Grid'
and
'button[id$=View]': {
click: this.onClickViewBtn
},
and
onClickViewBtn: function(btn) {
var centerContainer = this.getCenterContainer(),
item = centerContainer.down(btn.xtypeToOpen); // Here I use the argument.
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With