Categories | Question details Back To List | ||
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 http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=6274&ssr=yes&s=selectItem and http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=3487&ssr=yes&s=selectItem dosnt seems to work either for me. i assume the "id" is the tree address or the in like in <item id="0_1_1_0"> 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"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title></title> <link rel="shortcut icon" href="favicon.ico"> <link rel="stylesheet" type="text/css" href="css/yetii.css"> <link rel="stylesheet" type="text/css" href="css/comments.css"> <link rel="stylesheet" type="text/css" href="css/fp_style.css"> </head> <body> <script src="js/codebase/dhtmlxcommon.js"></script> <script src="js/codebase/dhtmlxtree.js"></script> <div id="treeboxbox_tree" style="overflow:auto;"></div> <script> var id="0_1_1"; tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("js/codebase/imgs/csh_vista/"); tree.setXMLAutoLoading("frm_treeview.php?f=0"); tree.loadXML("frm_treeview.php"); tree.selectItem(id); tree.openItem(id); tree.focusItem(id); tree.setOnClickHandler(doOnClick); function doOnClick(nodeId) { var myUrl = tree.getUserData(nodeId,"targeturl"); parent.content.location.href = myUrl; } </script> </body> </html> [/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? Answer posted by Support on Feb 24, 2009 03:06 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); }); Answer posted by Daniel on Feb 24, 2009 13:33 thanks, but i tried that before and it didn't work as expected. this is what i have now: <script> tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("js/codebase/imgs/csh_vista/"); tree.setXMLAutoLoading("frm_treeview.php?f=0"); var id = "0_1"; tree.loadXML("frm_treeview.php",function(){ tree.selectItem(id); tree.openItem(id); tree.focusItem(id); }); tree.setOnClickHandler(doOnClick); function doOnClick(nodeId) { var myUrl = tree.getUserData(nodeId,"targeturl"); parent.content.location.href = myUrl; } </script> 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. Answer posted by Support on Feb 25, 2009 06:04 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"); |