Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vibhav Agrawal on Oct 29, 2009 05:11
open dhtmlx forum
How to load the child nodes dynamically on re-expansion of a Tree Node

Hi,

I am facing an issue related to Tree.
I have a tree with some child nodes upto 5 level depth.

I am using dynamic model of loading the tree nodes (using setAutoLoadXML(..)). Whenever user expands the tree for the first time, the event set by setOnOpenHandler is called and the URL specified is called to find the child tree nodes.
But, if user closes that tree and again opens, then i need to fetch the data again from server by the specified URL. But currently it simply expands the tree without fetching the data from server (ie, using the cache which was returned on first expansion).

Is there any setting on tree component OR any work around by which i can get the child nodes dynamically from server everytime user expands the tree node?

Thanking You,

Vibhav Agrawal
Answer posted by Alex (support) on Oct 29, 2009 10:54

Hello,

tree loads a branch only once - when nodes opens for the first time. You can set onOpenStart event handler and force branch loading. It can be done as follows: 

tree.attachEvent("onOpenStart",function(id,state){

    if(state<1 && tree._idpull[id].XMLload)
        tree.refreshItem(id);
    return true;
})