简体   繁体   English

Extjs-树面板展开事件

[英]Extjs - Tree Panel expand event

I want to create a tree panel and add an event to it when expand node, but code seems not work for me. 我想创建一个树面板,并在展开节点时向其中添加一个事件,但是代码似乎对我不起作用。 I've already searched google for hours but no luck. 我已经在Google搜索了几个小时,但没有运气。 Could anyone take a look and tell me why? 谁能看看并告诉我为什么?

Here is my 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');
            }
        }
    });
});

Thanks in advance! 提前致谢!

You used the wrong event. 您使用了错误的事件。 You need to use afteritemexpand event. 您需要使用afteritemexpand事件。

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

Here's a fiddle: 这是一个小提琴:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM