Categories | Question details Back To List | ||
Open tree node by script I am trying to get my tree to open by a specific ID, so for instance a function like tree.openItem(1); or tree.openItem('1'); where 1 = ID of the node. I am not getting any response at all, I have also tried: tree.openItemsDynamic('1',true) But that doesnt work, I get an error saying, "XMLload is null or not an object". Are there any more detailed documentation than what is online, so I can get to grips with all this? With thanks John My code: <script src="/scripts/codebase/dhtmlxcommon.js"></script> <script src="/scripts/codebase/dhtmlxtree.js"></script> <script src="/scripts/codebase/ext/dhtmlxtree_dragin.js"></script> <script src="/scripts/codebase/dhtmlxdataprocessor.js"></script> <script src="/scripts/codebase/ext/dhtmlxtree_xw.js"></script> <script src="/scripts/codebase/ext/dhtmlxtree_li.js"></script> <div id="treeboxbox_tree" style="width:100%;height:100%"></div> <script> tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("/scripts/codebase/imgs/csh_bluefolders/"); tree.enableDragAndDrop(true); tree.setDragBehavior("complex"); XMLURL = "/inc_tree_functions_v2_data.asp?blnOnlyFolders=0&blnShowShared=0&blnShowAllShared=0&intContentType=&intUserID=2&intPopupSelectWidow=0"; tree.loadXML(XMLURL); tree.setXMLAutoLoading(XMLURL); tree.openItemsDynamic('1',true) //this function does the ONCLICK event stored in xml as a function tree.setOnClickHandler(doOnClick); function doOnClick(nodeId){ var myUrl = tree.getUserData(nodeId,"function"); eval(myUrl); } myDataProcessor = new dataProcessor("inc_tree_functions_v2_processor.asp"); myDataProcessor.setOnAfterUpdate(function(nodeId,cType,newId){ alert("Item was "+cType+"d. Item id is " + newId) }); myDataProcessor.init(tree); function myErrorHandler(type, desc, erData){ alert("ERROR: " +erData[0].status) } dhtmlxError.catchError("ALL",myErrorHandler); </script> Answer posted by Support on Jun 27, 2008 04:49 Your code is correct, but the XML loading is async. process, which mean you need to wait while data loaded. The moment of data loading can be catched through onXLE event or by using second parameter of loadXML tree.loadXML(XMLURL,function(){ tree.openItem('1'); }); |