如何从 ExtJs 4 中的 (MVC) 控制器捕获树节点点击?
在我的 ExtJS 4 控制器中,我可以捕获页面上某些元素的事件。 例如,要捕获菜单项单击,我可以执行以下操作:
init: function() {
this.control({
'maintoolbar menuitem[action=contacts]': {
click: function() {
// do something ;
}
}
}).......
How do I do the same to catch tree node clicks?我非常想要与菜单项相同的效果(树的id为settingstree)。
编辑:这是树代码:
Ext.define('MyApp.view.system.SettingsTree',{
extend: 'Ext.tree.Panel',
requires: [
'Ext.data.TreeStore',
'MyApp.store.SettingsTree',
],
title: MyApp.locale.T('settings'),
defaults: {
expanded:true
},
id:'settingstree',
store: Ext.create('MyApp.store.SettingsTree'),
alias: 'widget.settingstree',
rootVisible: false,
useArrows: true,
/*listeners: {
itemclick: function(view, record, el, index, ev, options ) {
console.log(arguments);
}
}*/
});
请注意,我故意注释掉了 itemclick 侦听器。虽然这确实报告了我单击的所有节点,但我更喜欢在控制器中捕获它,因为我应该......
有什么想法吗?
谢谢!
In my ExtJS 4 controllers I can catch events on certain elements on the page.
For example, to catche menu items clicks I can do:
init: function() {
this.control({
'maintoolbar menuitem[action=contacts]': {
click: function() {
// do something ;
}
}
}).......
How do I do the same to catch tree node clicks? I pretty much want the same effect as the menu item (the tree has the id of settingstree).
EDIT: here's the tree code:
Ext.define('MyApp.view.system.SettingsTree',{
extend: 'Ext.tree.Panel',
requires: [
'Ext.data.TreeStore',
'MyApp.store.SettingsTree',
],
title: MyApp.locale.T('settings'),
defaults: {
expanded:true
},
id:'settingstree',
store: Ext.create('MyApp.store.SettingsTree'),
alias: 'widget.settingstree',
rootVisible: false,
useArrows: true,
/*listeners: {
itemclick: function(view, record, el, index, ev, options ) {
console.log(arguments);
}
}*/
});
Note that I intentionally commented out the itemclick listener. While this does report me on ll nodes clicked, I prefer to catch that in the controller, as I should...
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将:
在适当的控制器中
You can put:
in appropriate controller