View Full Version : Is it possible to load a Tree without call to server

8 Apr 2010, 8:18 AM
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
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:


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

return node;

8 Apr 2010, 4:44 PM
What about reading the API?


9 Apr 2010, 9:36 AM
It's a very big API and I've definitely been reading it. Is there something I missed?

9 Apr 2010, 9:55 AM
No. I hadn't seen your second post when I reply. :)