selecting a node in dhtmlXTreeObject (again...)

Hi there,



im trying to figure out how to open the tree to a given node, but i cant get it to work. i dont even get an error.

i tried dhtmlx.com/docs/products/kb/ … selectItem dosnt seems to work either for me.

i assume the “id” is the tree address or the in like in in my xml, correct?



here is my code:



[code]


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
http://www.w3.org/TR/html4/loose.dtd”>






































[/code]



the tree is there and i can open and navigate it, however it ignores all my attempts to select a node id. nothing happens, nothing is selected and i dont get an error message in firebug or anything.

what seems to be the issue here?

Data loading is async. , which means - you need to catch the moment when data really loaded and only after that, execute commands against data. To do so you can use onXLE event or second parameter of loadXML command

tree.loadXML(“frm_treeview.php”,function(){
tree.selectItem(id);
tree.openItem(id);
tree.focusItem(id);
});

thanks, but i tried that before and it didn’t work as expected.
this is what i have now:



at this point it opens the tree to 0_1. however, if i replace var id=‘0_1’ with var id=‘0_1_0’ or any other valid address deeper in the tree it wont work and keeps the whole tree closed. if i open frm_treeview.php?id=0_1_1 it gives me the expected result as an xml response.

When top level of tree loaded , component know only IDs of loaded items, so it will ignore any command with unknown item ID.
Pro version of dhtmlxtree supports
tree.openItemsDynamic

tree.openItemsDynamic(“0_1,0_1_0”);

with such command, tree will open branch 0_1, load related data, and open item 0_1_0 in newly loaded branch.