0

在我的 ExtJS 4 控制器中,我可以捕捉页面上某些元素的事件。例如,要捕获菜单项点击,我可以这样做:

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 监听器。虽然这确实报告了我点击的所有节点,但我更喜欢在控制器中捕获它,因为我应该......

有任何想法吗?

谢谢!

4

1 回答 1

2

你可以放:

this.control({
        'settingstree': {
            itemclick: function() {
                                // do something ;
                            }
                    }
            })

在适当的控制器中

于 2011-07-29T12:18:01.487 回答