This is a migrated thread and some comments may be shown as answers.

Timing Issues in expand

3 Answers 25 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mandar
Top achievements
Rank 1
Mandar asked on 21 Jun 2010, 12:54 PM
I have a RadTree which is bound to a data source. I want to display the data associated with the first leaf node whenever a root node is selected. I am doing this using the following code:
var node = tree.get_selectedNodes()[0]; 
 
node.expand() 
 
//alert("node text = " + node.get_text() + "\nChild count: " + node.get_nodes().get_count()); 
 
             
 
            while (node.get_nodes().get_count() != 0)  
 
            { 
 
                node = node.get_nodes().getNode(0); 
 
                node.expand(); 
 
                //alert("node  = " + node.get_text() + "\nchild count = " + node.get_nodes().get_count()); 
 
            } 

I have debugged the code using Firebug and know that its working exactly as its supposed to. The problem I am facing is that whenever I am not in debug mode, if I expand the root node it just shows me the content associated with the root node. I even tried putting alert() statements after the node.expand() call and it shows no. of child nodes as 0, even though there are child nodes present. Also, the code works perfectly well if the root node is already expanded. Funny thing is, if I enable the first alert() call, the whole thing works perfectly!! Makes me believe there are timing issues with the expand() call. Any ideas? Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 23 Jun 2010, 03:19 PM
Hello Mandar,

What is the expand mode of the nodes?
Probably currently the expand mode of the nodes is set to "ServerSide", and when you tested the script (debugged it) you used the "ClientSIde" expand mode.

If that is the case you need to set the expand mode of the nodes to "ServerSideCallBack".

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mandar
Top achievements
Rank 1
answered on 23 Jun 2010, 03:59 PM
Hi Nikolay

For the non-leaf nodes, the ExpandMoode is ServerSideCallBack and for leaf node it is ClientSide. When the Node Expand event occurs, I call a method which checks every item of the data source to see if it is to be a leaf node in the tree. Accordingly, I set the ExpandMode property.

if (!dataNode.isLeafNode) 
                { 
                    node = new RadTreeNode(dataNode.nodeText, dataNode.nodeID.ToString()); 
                    node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
                } 
                else   
                { 
                    node = new RadTreeNode(dataNode.nodeText, "L" + dataNode.nodeID.ToString()); 
                    node.ExpandMode = TreeNodeExpandMode.ClientSide; 
                } 

isLeafNode is a member of my custom class which tells me if the node is to be a leaf node in the RadTree. If it is going to be a leaf node, then I append a "L" to the value for later identification.
0
Nikolay Tsenkov
Telerik team
answered on 28 Jun 2010, 11:46 AM
Hello Mandar,

Which event do you trap?
If it's ClientNodeExpanding, then this is the problem, because the node, hasn't really been expanded, yet.
Try switching to a later event as ClientNodeExpanded and it should expand the items as you require.

Also, what exactly did you meant by "I want to display the data associated with the first leaf node whenever a root node is selected."? I thought you meant its first child node to be expanded, and the first child of it's first child node to be expanded etc.
Maybe I didn't get your requirements right, but this is what your code (your first post) does.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Mandar
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Mandar
Top achievements
Rank 1
Share this question
or