Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Corejava boy on Jan 05, 2008 10:23
open dhtmlx forum
open a link when a node is clicked

Hi

I am used DHTMLX tree to display tree. Now I need to open a link on the left clcik of a node.
How to do it

Thanks
Answer posted by Support on Jan 14, 2008 09:39
something similar to next must work

    tree.attachEvent("onClick",function(id){
       window.open(any_url_here)
    });
Answer posted by Àlex Corretgé on Jan 17, 2008 10:57
Try to:

- Add a userdata field called "url"
<item text="Google" id="66"  im0="book.gif"  im1="books_open.gif" im2="books_close.gif" child="0"><userdata name="url"><![CDATA[http://google.com/]]></userdata></item>

- Set a onClickHandler

40 tree.setOnClickHandler(onNodeSelect);//set function object to call on node select
42 //see other available event handlers in API documentation
43 function onNodeSelect(nodeId)
44 {
45 var link = tree.getUserData(nodeId,"url");
46 if (link != undefined)
47 {
49 top.frames['peMain'].location.href = link;
50 }
52 }


And run perfectly.

Fins aviat...
Àlex Corretgé