Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by raj on Apr 14, 2008 22:24
open dhtmlx forum
load tree dynamically on click of a button

Hi,

I am using dhtmlXtree in my application,

I have already loaded the tree using below code, after getting the tree populated,I wants to load the tree with different values dynamically when onclick of button...
In my JSP I have a button called LOADTREE, I want to load the tree onclick of this button,
So, how do I load tree dynamically on click of a button?


here is my code:

<table>
<tr valign=top>
<td valign="top">

<div id="treebox_tree" style="border :0px;overflow:off;filter:alpha(opacity=100);-moz-opacity:0.6; z-index:1000; " ></div><br>

</td>
</tr>
</table>
<script type="text/javascript" language="JavaScript">

var tree=new dhtmlXTreeObject("treebox_tree","100%","100%",0);
if(tree != null && typeof(tree) != "undefined"){

tree.setImagePath("images/treeImgs/");
tree.enableSmartXMLParsing(true);
tree.enableHighlighting(true);
tree.setXMLAutoLoading('myPage.do?param1='+param1value+'¶m2='+param2value);
tree.loadXML('myPage.do?param1='+param1value+'¶m2='+param2value);

}

</script>

I have tried the below way to load the tree dynamically, I had called the method tree.loadXML('myPage.do?param1='+param1value+'¶m2='+param2value);

when onclick of the button, but the tree is getting appended to the old tree. So is there any way to load the tree dynamically?

Answer posted by Support on Apr 15, 2008 02:47
>>I have tried the below way to load the tree dynamically, I had called the method tree.loadXML('myPage.do?param1='+param1value+'m2='+param2value);
>>when onclick of the button, but the tree is getting appended to the old tree. So is there any way to load the tree dynamically?

The logic is the next - if you need to reload tree, then you need to call
    tree.deleteChildItems(0);
to delete existing tree and call
    tree.loadXML(url);
to load new dataset.
The url must contain any necessary parameters to server side script