首页 > 解决方案 > 如何在 Extjs 中的树存储数据中添加新根作为现有节点的父节点

问题描述

我正在研究一个树组合框(组合框内的树面板),我有一个树存储来加载树组合框。

我想提供全选功能,所以想添加一个新的根,它将成为现有树存储数据的父级。

树店:

var store = new Ext.data.TreeStore({
                        root: {
                            expanded: true,
                            children: [
                                { text: "Numbers", expanded: false, children: [
                                    { text: '1', leaf: true },
                                    { text: '2', leaf: true },
                                    { text: '3', leaf: true },
                                    { text: '4', leaf: true },
                                    { text: '5', leaf: true },
                                ] },
                                { text: "Letters", expanded: true, children: [
                                    { text: 'A', leaf: true },
                                    { text: 'B', leaf: true },
                                    { text: 'C', leaf: true },
                                    { text: 'D', leaf: true },
                                    { text: 'E', leaf: true },
                                ] },
                                { text: "Colors", expanded: false, children: [
                                    { text: 'Red', leaf: true },
                                    { text: 'Green', leaf: true },
                                    { text: 'Blue', leaf: true }
                                ] }
                            ]
                        }
                    });

标签: extjstreepanelextjs6.5treestore

解决方案


推荐阅读