在我的 ExtJS 4 Controller 中,我可以捕获页面上某些元素上的事件。 例如,要捕捉菜单项的点击,我可以这样做:
init: function() {
this.control({
'maintoolbar menuitem[action=contacts]': {
click: function() {
// do something ;
}
}
}).......
我如何做同样的事情来捕获树节点点击?我非常想要与菜单项相同的效果(树的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 监听器。虽然这确实报告了我单击的所有节点,但我更喜欢在 Controller 中捕获它,因为我应该......
有什么想法吗?
谢谢!
最佳答案
您可以输入:
this.control({
'settingstree': {
itemclick: function() {
// do something ;
}
}
})
在适当的 Controller 中
关于javascript - 如何从 ExtJs 4 中的 (MVC) Controller 捕获树节点点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6871293/