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:
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!
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!