How to add new root as parent for existing nodes in tree-store data in Extjs

196 Views Asked by At

I am working on a tree-combobox(tree-panel inside combobox) where I have a tree-store to load tree-combobox.

I want to provide the feature to select all, so want to add a new root which will be the parent for existing tree-store data.

Tree-Store:

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 }
                                ] }
                            ]
                        }
                    });
0

There are 0 best solutions below