-
20 Nov 2011 5:01 AM #1
Treestore: load nodes but not expand all. How?
Treestore: load nodes but not expand all. How?
Hello everybody!
I need your help: I have a treestore configured with Ajax proxy. RootNode is expanded, but child nodes are not. I want when tree is shown, treestore load ALL nodes, but not expand them. So when root node loads it childs, every child node loads it own childs... but they are collapsed.
How I can achieve this?
Thanks
-
20 Nov 2011 7:03 AM #2
Can't you load all the data at once? Tree's can be loaded with all data once in a recursive style.
-
20 Nov 2011 7:06 AM #3
Tree uses ajax proxy, which loads child nodes after node is being expanded. I need that when tree is loaded, it also loaded all childs.
-
20 Nov 2011 7:15 AM #4
Okay, but tree's support this (in JSON)
This way you can load all nodes in one request. When specifying the properties of the children you can specify your 'rootProperty' again to specify the childnodes. This way you can recursivly deliver the whole tree at onceCode:{ success: true, nodes: [{ },{ text: 'aap', nodes: [{ text: 'bier', nodes: [{ }] },{ }] }] }
-
20 Nov 2011 7:21 AM #5
That works fine if you have static child nodes or you know their quantity. In my case I set the root node, which contains url for its child nodes. And every child node has its own url to it childs. when root node expands, I read url for it childs, proxy via ajax receives response (json) and builds child nodes in tree.
-
20 Nov 2011 9:29 AM #6
Fix which did all I needed:
Code:store.on('load', function(store, node) { Ext.each(node.childNodes, function (item, index, allItems) { if(!item.isLoaded() && !item.isLeaf()) { store.load({node: item}); } }); });
-
8 Mar 2012 12:38 PM #7
Could you share your full code on the tree, store, and models. I have a similar issue where each node has an association model that has its own proxy and I am trying to figure out how to connect these things together.


Reply With Quote