Extjs 3.31 TreeGrid implements static page loading of json into TreeGrid

Source: Internet
Author: User

What should I do if I want to achieve the TreeGrid effect without opening the official example? I implemented it in this way. Copy codeThe 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.