Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mohit Maniar on May 12, 2009 08:29
open dhtmlx forum
dhtmlxTree -- setAutoLoading (Dynamical Loading in dhtmlxTree v.1.x)

Hi,

I need your help with setAutoLoading feature in dhtmlxTree.

Parent.xml:

<?xml version="1.0" encoding="iso-8859-1" ?>
<tree id="0">
<item text="Surveillance" id="a1" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="1" />
<item text="Apple" id="app" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="1" />
</tree>

Child.xml:

<?xml version="1.0" encoding="iso-8859-1" ?>
<tree id="a1">
    <item text="Hello" id="a3" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/>
<item text="Hel" id="ga3" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/>
</tree>

<tree id="app">
    <item text="Aapple11" id="Aapple11" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/>
<item text="Aapple111" id="Aapple111" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/>
</tree>

JS:
function callTree(){
var tree;
    tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"400%","150%",0);;
    tree.setImagePath("codebase/imgs/");
    tree.enableCheckBoxes(false);
    tree.setXMLAutoLoading("http://localhost/xml/Child.xml");
    tree.loadXML("http://localhost/xml/Parent.xml");//load root level from xml
}


Issue:

While browsing the top node, it give an loadxml error. According to "Dynamical Loading in dhtmlxTree v.1.x" documentation, this should work as for each parent "id" you have a corresponding child "id" in the <tree> </tree> format.

Kindly help.

Thanks,
Mohit.
Answer posted by Alex (support) on May 13, 2009 01:29

Hello, 

child.xml is incorrect - there are two <tree> nodes.

You should set the path to the server-side script that will generate either:

 <?xml version="1.0" encoding="iso-8859-1" ?> 
<tree id="0"> 
<item text="Surveillance" id="a1" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="1" /> 
<item text="Apple" id="app" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="1" /> 
</tree>

for "a1"

or 

<?xml version="1.0" encoding="iso-8859-1" ?> 

<tree id="app"> 
  <item text="Aapple11" id="Aapple11" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/> 
<item text="Aapple111" id="Aapple111" im0="dhtmlxtree_icon.gif" im1="dhtmlxtree_icon.gif" im2="dhtmlxtree_icon.gif" child="0"/> 
</tree>

for "app".

Please, take a look at the article: http://dhtmlx.com/docs/products/dhtmlxTree/doc/dyn_loading.html

If you have PRO edition, you can set custom "autoloading" function that will load different static xml files for a specific node.

tree.setXMLAutoLoadingBehavior("function");
tree.setXMLAutoLoading(function(id){
 /*your code here*/
});