Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by raj on Apr 14, 2008 07:28
open dhtmlx forum
tree load dynamically on button click

Hi,

I am using dhtmlXtree in my application,
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>
Answer posted by Support on Apr 14, 2008 07:49
If I understood correctly the code must look like

<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+'&param2='+param2value);
}
function load_tree(){
    tree.deleteChildItems(0);
    tree.loadXML('myPage.do?param1='+param1value+'&param2='+param2value);   
}
</script>
<input type="button" name="somw" value="load" onclick="load_tree();">