问题
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!
回答1:
You can put:
this.control({
'settingstree': {
itemclick: function() {
// do something ;
}
}
})
in appropriate controller
来源:https://stackoverflow.com/questions/6871293/how-to-catch-tree-node-clicks-from-a-mvc-controller-in-extjs-4