【问题标题】:Extjs - Tree Panel expand eventExtjs - 树面板展开事件
【发布时间】:2016-09-23 16:15:25
【问题描述】:

我想创建一个树面板并在展开节点时向其中添加一个事件,但代码似乎不适合我。我已经在谷歌上搜索了几个小时,但没有运气。谁能看一下,告诉我为什么?

这是我的code

Ext.onReady(function () {
    var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            children: [{
                text: "detention",
                leaf: true
            }, {
                text: "homework",
                expanded: false,
                children: [{
                    text: "book report",
                    leaf: true
                }, {
                    text: "alegrbra",
                    leaf: true
                }]
            }, {
                text: "buy lottery tickets",
                leaf: true
            }]
        }
    });

    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody(),
        listeners: {
            afteritemexpand: function ( node, index, item, eOpts ){
                alert('HAHA');
            }
        }
    });
});

提前致谢!

【问题讨论】:

  • Awww 没关系,我的错,这应该添加到存储侦听器,而不是面板

标签: javascript extjs treepanel


【解决方案1】:

您使用了错误的事件。您需要使用afteritemexpand 事件。

afteritemexpand: function ( node, index, item, eOpts ){
    alert('HAHA');
}

这是一个小提琴:

http://jsfiddle.net/johanhaest/RDC9W/1/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多