Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Rachel H. on Nov 02, 2009 20:36
open dhtmlx forum
tree load xml issue

Hi there,

I have a tree that I initialize like this:

myTree = new dhtmlXTreeObject("treebox","100%","",0);
myTree.setImagePath("/media/icons/");
myTree.setIconSize(16, 16);
myTree.enableDragAndDrop(true);
myTree.enableHighlighting(true);
myTree.enableTreeLines(false);
myTree.enableIEImageFix(true);
myTree.attachEvent("onClick", doOnClick);
myTree.attachEvent("onBeforeDrag", doOnBeforeDragTree);
myTree.attachEvent("onDrag", doOnDragTree);
myTree.attachEvent("onDragIn", doOnDragInTree);

myTree.loadXML("/xmlgen/cm/tree?user_id=" + user_id + "&view_id=" + view_id);

Then later, I insert some new nodes of the tree into the database, and after that is accomplished I call this again:

myTree.loadXML("/xmlgen/cm/tree?user_id=" + user_id + "&view_id=" + view_id);

I would expect that it would refresh, but it does not.

Instead, it seems to build some additional tree nodes on top of the existing tree.

Any idea what might be happening and how I can fix?

Thanks!
Answer posted by Alex (support) on Nov 03, 2009 01:07

Hello,

in order to reload tree it is necessary to remove all nodes and only then load a new nodes. But in this case tree will be closed 

To restore open states you can try to use saveOpenStates and loadOpenStates methods:

myTree.saveOpenStates();

myTree.deleteChildItems(0);

myTree.loadXML("/xmlgen/cm/tree?user_id=" + user_id + "&view_id=" + view_id,doAfterLoading);

function doAfterLoading(){

    myTree.loadOpenStates();

}