Extjs树不会附加到树面板中的选定节点

Extjs树不会附加到树面板中的选定节点,extjs,treepanel,Extjs,Treepanel,我有一个树面板,我正试图添加一个吼叫下面的选定项目 如果单击“添加到根目录”,则它正在工作。 但是。如果单击“添加到选定项”,则该选项不起作用: Ext.application({ name: 'Fiddle', launch: function () { var store = Ext.create('Ext.data.TreeStore', { root: { expanded: true,

我有一个树面板,我正试图添加一个吼叫下面的选定项目

如果单击“添加到根目录”,则它正在工作。
但是。如果单击“添加到选定项”,则该选项不起作用:

Ext.application({
    name: 'Fiddle',

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

        Ext.create('Ext.tree.Panel', {
            //title: 'Simple Tree',
            itemId: 'projectTree',
            viewConfig: {
                plugins: {
                    ptype: 'treeviewdragdrop'
                }
            },
            id: 'projectTree',
            width: 200,
            height: 500,
            store: store,
            renderTo: Ext.getBody(),
            dockedItems: [{
                xtype: 'toolbar',
                dock: 'top',
                items: [{
                    text: 'Add To Selected',
                    handler: function () {
                        var treeNode = Ext.getCmp('projectTree').getSelectionModel().getSelection()
                        treeNode.appendChild({
                            text: 'Child 4',
                            leaf: false
                        });
                    }
                }, {
                    text: 'Add to root',
                    handler: function () {
                        var treeNode = Ext.getCmp('projectTree').getRootNode();
                        treeNode.appendChild({
                            text: 'Child 4',
                            leaf: false
                        });
                    }
                }]
            }],

        });
    }
});
getSelection()
以某种方式返回一个节点数组,因此只需获取第一个节点:

。。。
树节点[0]。追加子节点({
正文:“儿童4”,
叶:错
});

你说的“不起作用”是什么意思?你试过添加跟踪输出吗?@Thevs,它没有附加到child,看看我放的链接