Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bill Jindrich on Jun 25, 2008 15:39
open dhtmlx forum
dhtmlxTree: adding a URL to an item in the tree

In looking at the samples for dhtmlxTree, I don't see anything in the XML model that allows the specification of a URL for each item in the tree. We're thinking of using dhtmlxTree for the navigation for our web site. Is there a simple way to associate a launch URL with each tree item? I didn't expect that any custom coding would be needed, but now I'm not so sure.
Answer posted by Support on Jun 26, 2008 02:01
If you want the tree items to be a tags - just use inline HTML
<tree id="0">
    <item id="some"><itemtext><![CDATA[ <a href="http://any.url/here">any test</a>]]></itemtext></item>


( The itemtext supported in PRO edition only )

Or you can use userdata sections

<tree id="0">
    <item id="some" text="any text"><userdata name="url">http://some.url/here</userdata></item>

and on client side
tree.attachEvent("onClick",function(id){
    document.location.href=tree.getUserData(id,"url");
    return true;
});
Answer posted on Jun 05, 2009 14:58

Hello,

I have a question on same line...

In the following xml code for grid - how do I disable the onclick functionality for some folders ?

currently If I click on the folder "reporting" - I see error page "page cannot be found" on right side frame

<item text="Reporting" id="rpt" open="1">
   <item text="Repository1" id="rpt1">
   <userdata name="href">one.html</userdata>
   </item>  
   <item text="Reporting2" id="rpt2">
   <userdata name="href">two.html</userdata>
   </item></item>

..html snippet

tree.setOnClickHandler(doOnClick);
 function doOnClick(id){
 var Url = tree.getUserData(id,"href");
 parent.right.location.href = myUrl;

 

Please advise.

Thanks,

skm

Answer posted by Support on Jun 08, 2009 01:35
There is no way to disable event for some items, it will occur for each, but you can check value of attribute|userdata before executing any action. 


function doOnClick(id){
 var myUrl = tree.getUserData(id,"href");
 if (myUrl) // can be added
    parent.right.location.href = myUrl;
Answer posted on Jun 08, 2009 11:53

Thanks!

-skm