How to catch tree node clicks from a (MVC) controller in ExtJs 4?

若如初见. 提交于 2019-12-10 11:55:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!