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:
…
http://www.mylink.com>
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
It should be " 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:…
http://www.mylink.com
…
If problem persists - please provide more details - what issue you’ve got ? how it should work ? etc.
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:
blabla
I now, have extracted the extra information that I need from the ID tag. This workaround solves the problem for now.
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 )
1199882117.zip (48.4 KB)
I replaced my code with yours and it works. Thanks !
Roy