-
8 Apr 2010 8:18 AM #1
Is it possible to load a Tree without call to server
Is it possible to load a Tree without call to server
Is it possible to load a tree without a call to the server? If so, how is it done?
For example, say I have a JSON object stored already in a Javascript variable. I want to take that object and tell the tree to load it's nodes from that object.
The object is currently structured in such a way that it is identical to the object that would be returned from the server to load that same tree.
-
8 Apr 2010 1:59 PM #2
Solved
Solved
I figured this out.
Instead of using the tree loader I had to manually add tree nodes. Because the JSON object I have stored the data into already represented the structure to be used by the TreeLoader, I did the following:
Code:Ext.getCmp("componentId").setRootNode(getNodeFromJsonObject(jsonObject)); function getNodeFromJsonObject(object) { var node; var child; var i; node = new Ext.tree.TreeNode({ id: object.id, expanded: object.expanded, iconCls: object.iconCls, text: object.text }); if (typeof(object.children) != "undefined") { for (i = 0; i < object.children.length; i++) { child = getNodeFromJsonObject(object.children[i]); node.appendChild(child); } } return node; }
-
8 Apr 2010 4:44 PM #3
What about reading the API?
http://www.extjs.com/deploy/dev/docs/
http://www.extjs.com/deploy/dev/docs...TreePanel.html
-
9 Apr 2010 9:36 AM #4
Did I miss something?
Did I miss something?
It's a very big API and I've definitely been reading it. Is there something I missed?
-
9 Apr 2010 9:55 AM #5
No. I hadn't seen your second post when I reply.
___________
Sérgio Serra


Reply With Quote