如何从ExtJs 4中的(MVC)控制器捕获树节点单击? [英] How to catch tree node clicks from a (MVC) controller in ExtJs 4?

查看:37
本文介绍了如何从ExtJs 4中的(MVC)控制器捕获树节点单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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 ;
                            }
                    }
            }).......

我如何做才能捕获树节点的点击?我几乎想要与菜单项相同的效果(树的ID为settingstree).

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).

这是树代码:

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侦听器.虽然这确实报告了有关单击的ll个节点的信息,但我还是希望将其捕获到控制器中,因为我应该...

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...

有什么想法吗?

谢谢!

推荐答案

您可以输入:

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

在适当的控制器中

这篇关于如何从ExtJs 4中的(MVC)控制器捕获树节点单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆