Categories | Question details Back To List | ||||||||
link in userdata field of treexml fails Hi, I want to have a http link in a treenode and I use the userdata field in combination with tree onclickhandler to get it to work. Somehow this doesn't work as I expected. I use following code: Tree XML: ... <item text="parentnode text" id="parent1"> <userdata name="myurl">http://www.mylink.com></userdata> <item text="Childenode text" id="child1" /> </item> etc. Tree definition with Onclick handler: tree0=new dhtmlXTreeObject("mytree","100%","100%",0); tree0.setImagePath("imgs/"); tree0.enableDragAndDrop(true); tree0.enableThreeStateCheckboxes(true); tree0.setItemImage("books_close.gif"); tree0.enableDragAndDrop(true); tree0.setOnClickHandler(doOnClick); function doOnClick(nodeId){ var myUrl = tree0.getUserData(nodeId,'myurl'); window.open(myUrl); } tree0.loadXML("mytree.xml"); What happen is that javascript variable myUrl gets the value: undefined. It is not filled with the userdata as defined in the XML What goes wrong here? regards, Roy Answer posted by Support on Jan 08, 2008 03:06 It should be " www.mylink.com " instead of " www.mylink.com> ". When you click on "parent node text" item page has to be loaded. If you want to add user data for "Childenode text" you should use following xml:... <item text="parentnode text" id="parent1"> <item text="Childenode text" id="child1" > <userdata name="myurl">http://www.mylink.com</userdata></item> </item>.... If problem persists - please provide more details - what issue you've got ? how it should work ? etc. Answer posted by Roy on Jan 08, 2008 12:52 Thanks for your answer. Sorry for the typo (>) but the problem persists. Javascript variable myUrl stays undefined, even when I put in a very simple userdata text such as blabla. The userdata is supposed to be related to the parent node so the xml below should be correct to my opinion: <item text="parentnode text" id="parent1"> <userdata name="myurl">blabla</userdata> <item text="Childenode text" id="child1" /> </item> I now, have extracted the extra information that I need from the ID tag. This workaround solves the problem for now. Answer posted by Support on Jan 09, 2008 04:26 Please check attached sample , it use code and XML similar to used in your case, and it works correctly. Problem may be caused by version of dhtmlxTree which you are using ( if you are using not latest code - please try latest one ) Attachments (1)
Answer posted by Roy on Jan 09, 2008 11:05 I replaced my code with yours and it works. Thanks ! Roy |