Ani*_*der 4 javascript extjs extjs5
我有一个视图 - 基本上是一个面板...我有菜单按钮.....按钮内的4个菜单...我想每次调用控制器中存在的一个特定功能但是参数不同...这怎么可能 ?
xtype: 'button',
menu: {
items: [{
text : 'menu 1',
listeners: {
click: 'controllerfunction' //with argument 1
}
}, {
text : 'menu 2',
listeners: {
click: 'controllerfunction' // with argument 2
}
}]
}
Run Code Online (Sandbox Code Playgroud)
Jua*_*des 10
亚历山大的方式有效,但还有另一种方式更符合您使用的风格.
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') {
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅https://fiddle.sencha.com/#fiddle/15c7
我使用以下内容:
xtype: 'button',
xtypeToOpen:'listView', // This is the argument.
id: 'btnListView',
text: 'List'
Run Code Online (Sandbox Code Playgroud)
和
xtype: 'button',
xtypeToOpen:'gridView', // This is the argument.
id: 'btnGridView',
text: 'Grid'
Run Code Online (Sandbox Code Playgroud)
和
'button[id$=View]': {
click: this.onClickViewBtn
},
Run Code Online (Sandbox Code Playgroud)
和
onClickViewBtn: function(btn) {
var centerContainer = this.getCenterContainer(),
item = centerContainer.down(btn.xtypeToOpen); // Here I use the argument.
...
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4471 次 |
最近记录: |