How to catch tree node clicks from a (MVC) controller in ExtJs 4?
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 ;
开发者_JAVA技巧 }
}
}).......
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!
You can put:
this.control({
'settingstree': {
itemclick: function() {
// do something ;
}
}
})
in appropriate controller
精彩评论