openAllItems() ignored after loadXML()

I have a tree which was created on a layout like this:

dhxTree = dhxMainLayout.cells(“b”).attachTree();

I load the content of the tree from the server via a servlet:

dhxTree.loadXML(“bch”);

The tree loads successfully, but is always collapsed. I want the tree to be opened completely after
load.

I have tried every API i can find but the tree is always collapsed:

Examples:
dhxTree.openOnItemAdding(true);
dhxTree.openAllItems(0);
dhxTree.openAllItems();
dhxTree.openAllItems(‘0’;

Also, after refreshing the tree, again it is rendered as collapsed:

dhxTree.deleteChildItems(0);
dhxTree.loadXML(“bch”);

I’m sure it is something simple, but can’t find any other posts with a similar problem. Can you help?

Thanks

loadXML loads data asynchronously. So, you need to call item opening from onLoadingEnd handler:

dhxTree.loadXML(“bch”,function(){
dhxTree.openAllItems(0);
});

I’m also using openAllItems in the afterCall function of loadXML. However, I have an array of trees that I need to refresh, and apparently the tree name cannot be dynamic in the afterCall function.

My code:

for (var i = 1; i < anzBaum; ++i) { loadURL = "http://xxx.cfm?spalte=" + i; Baum[i].deleteChildItems(0); Baum[i].enableDragAndDrop(true,false); Baum[i].loadXML(loadURL,function(){Baum[i].openAllItems(0);}); }
throws error “‘Baum[…]’ is Null oder not an Object”. I tried to pass “i” as a parameter in the function call:

Baum[i].loadXML(loadURL,function(i){Baum[i].openAllItems(0);});

which gives the same error.

Calling an external function as afterCall function and passing “i” as parameter gives no error, but doesn’t open the items:

function openAfterLoading(n) { Baum[n].openAllItems(0); } [...] Baum[i].loadXML(loadURL,openAfterLoading(i));
What can I do to open all items after the tree refresh?