refreshItems not adding nodes

I am using the dhtmlXTree. I have a requirement to load most of the tree, perhaps 3/4. There is a top level node, let’s call it A that will have at most two descendant levels.



A

->B

->->C



Level A as well as all level B’s will be loaded. When clicking on level B, the child nodes of level B will be loaded dynmically from the server.



I am able to get the correct data back, but refreshItems doesn’t seem to be putting them anywhere. There are no errors given, either.



Here is how I load my tree initially.



    function loadTree(gci) {

        tree=new dhtmlXTreeObject(“treebox_tree”,“100%”,“100%”,0);

        tree.setImagePath("<%=request.getContextPath()%>/images/dhtmlx/");

        tree.enableDragAndDrop(1);

        tree.attachEvent(“onDrag”,leftTreeOnDrag);

        tree.attachEvent(“onClick”,refreshTheClickedNode);

        tree.loadXML(“xmlData?action=getData”);

    

    }





Here is how I am trying to refresh the nodes.



    function refreshTheClickedNode(nodeId) {

     var array = new Array();

     array[0] = nodeId;

     alert(‘subitems before:’ + tree.getAllSubItems(nodeId));

     tree.refreshItems(array,“xmlData?action=refresh”);

     alert('subitems after: ’ + tree.getAllSubItems(nodeId));

    }





The id of the clicked link is: “001344746”



The data returned looks like this:

















I get no errors, but neither does the refreshed node show any children. Making a call to getAllSubItems, to check if anything was added, does not return anything neither before, nor after the call.



Thanks for your help.

Tree supports two items
a) tree.refreshItem
    this method refetch child branch of item, supports only one node per call
b) tree.refreshItems
    this method supports many nodes per call , but updates only nodes specified as parameters, no new child will be added

Just update in you code

var array = new Array();

     array[0] = nodeId;

     alert(‘subitems before:’ + tree.getAllSubItems(nodeId));

     tree.refreshItems(array,“xmlData?action=refresh”);


with

     tree.refreshItem(nodeId,“xmlData?action=refresh”);