Extjs -在窗口中显示树的最佳方式

Extjs - Best way to show a tree in a window

本文关键字:最佳 方式 显示 窗口 Extjs      更新时间:2023-09-26

这是我使用的树形面板:

var tree = Ext.create('Ext.tree.Panel', {
                store: mystore,
                rootVisible: false,
                useArrows: true,
                frame: true,
                title: 'Organization Tree',
                renderTo: 'org-filter-window',
                width: 600,
                height: 400,
                dockedItems: [{
                    xtype: 'toolbar',
                    items: [{
                        text: 'Expand All',
                        handler: function () {
                            tree.expandAll();
                        }
                    }, {
                        text: 'Collapse All',
                        handler: function () {
                            tree.collapseAll();
                        }
                    }]
                }]
            });

我有这个窗口

  var orgWindow = Ext.create("Ext.Window", {
        store: myStoe,
        title: 'Organization Tree',
        width: 600,
        height: 400,
        html: '<div id="org-filter-window"></div>'
    });

不知道在窗口里面展示一棵树的最佳方式是什么。正如你所看到的,我已经尝试在窗口html内渲染树面板,它工作得很好,但我不确定这是否是首选的方式。

版本:Ext JS 4.0.7

如何:

var orgWindow = Ext.create("Ext.Window", {
        store: myStoe,
        title: 'Organization Tree',
        width: 600,
        height: 400,
        items: tree // <--- the only change is here
    });

并从tree定义中删除renderTo: 'org-filter-window',