Extjs3.31TreeGrid my small changes, achieve static page loading json into TreeGrid to achieve the TreeGrid effect, open the official example but do not see the effect, what should I do? I implemented it in this way.
The Code is as follows:
Var root = new Ext. tree. TreeNode ({
Text: 'root node ',
Expanded: true
});
Tree. setRootNode (root );
Var nodes = {};
Nodes. children = mydata;/* json data of TreeGrid [{......}, {……}] */
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,
Based on the principle of loading json data to the tree, we can load json data to treeGrid in this way, instead of dataUrl: 'treegrid-data. isn't it very easy to load the json file like this?