I want to achieve the effect of TreeGrid, but I can’t see the effect when I open the official example. What should I do? This is how I implemented it
var root = new Ext.tree .TreeNode({
text: 'Root node',
expanded: true
});
tree.setRootNode(root);
var nodes = {};
nodes. children = mydata;/*TreeGrid’s json data [{…},{…}]*/
function appendChild(node, o) {
if (o.children != null && o.children. length > 0) {
for (var a = 0; a < o.children.length; a ) {
var n = new Ext.tree.TreeNode({
task:o.children [a].task,
duration:o.children[a].duration,
user:o.children[a].user,
iconCls:o.children[a].iconCls
});
node.appendChild(n);
appendChild(n, o.children[a]);
}
}
}
appendChild(root, nodes);
Looking at the source code, we know that TreeGrid inherits from TreePanel
So root is the data source instead of store.
According to the principle of loading json data into the tree, similarly we can load json data like this Go to treeGrid and no longer worry about loading methods like dataUrl: 'treegrid-data.json'. Isn't it very simple?