I am trying to use the function openItemsDynamic on a tree to open multiple nodes (multi selection tree). If I call the function more than once, it seems to lock up the browser (IE with a stack overflow) or confuse the tree rendering (Firefox). Calling the method only once seems to work fine.
Can you suggest a way to open multiple nodes on a dynamic tree?
Thank you.
If I call the function more than once, it seems to lock up the browser
If you will run its second time, while first run not finished yet ( possible because of async. XML loading ) - the problem may appear.
But you can use the same command, just use all item IDs at once.
Instead of
tree.openItemsDynamic(“1,2,3”);
tree.openItemsDynamic(“4,5,6”);
you can use
tree.openItemsDynamic(“1,2,3,4,5,6”);
I have this same issue, but I am using a single call like:
tree.openItemsDynamic(“1,2,3,4,5,6”);
I have 3 trees in the page using openItemsDynamic method but all use different ID’s etc and do not run at the same time. It seems to stop on the 3rd ID.
It actually happens in Firefox as well… says this:
too much recursion
dhtmlx/tree/dhtmlxtree_xw.js
Line 23
too much recursionSituation can occur if you have�- non unique IDs in tree, same IDs used for few different items�- you have multiple � tree.openItemsDynamic calls against the same treeIf none of above actual in your case , please provide a sample of init code , for which issue occurs ( you can send it directly to support@dhtmlx.com )
We don’t use multiple calls to the same tree. But it seems to be a hit or miss (errors out usually but 1 out of 20 tries seems to work) so it looks as if it may be a loading issue as if its not waiting for the previous ID to load.
Ok some more debugging and I have narrowed it down.
If we use:
tree.openItemsDynamic(“2,95,94,4”);
When attaching it to the onXLE event like:
tree.attachEvent(“onXLE”,function() {
tree.openItemsDynamic(“2,95,94,4”);
});
It fails.
But if we put it in the function for loading XML like:
tree.loadXML("’.$url.’",function(){
tree.openItemsDynamic(“2,95,94,4”);
});
It works fine.
I think it has to do with your code in: dhtmlxtree_xw.js
dhtmlXTreeObject.prototype.openItemsDynamic=function(list,flag){
this._opnItmsDnmcFlg=convertStringToBoolean(flag);
this.onLoadReserve = this.onXLE;
this.onXLE=this._stepOpen;
this.ClosedElem=list.split(",").reverse();
this._stepOpen(this)
};
dhtmlXTreeObject.prototype._stepOpen=function(that){
if(!that.ClosedElem.length){
that.onXLE = that.onLoadReserve;
if (that._opnItmsDnmcFlg)that.selectItem(that.G_node,true);
if ((that.onXLE)&&(arguments[1])) that.onXLE.apply(that,arguments);
that.callEvent(“onOpenDynamicEnd”,[]);
return;
};
that.G_node=that.ClosedElem.pop();
var temp=that._globalIdStorageFind(that.G_node);
if (temp.XMLload===0)
that.openItem(that.G_node);
else{
that.openItem(that.G_node);
that._stepOpen(that)
}
};
I am not an expert in javascript but it looks to me like its going to continuously loop on the onXLE function?
Actually there are two problems, one caused by the way how you call command - onXLE event triggered each time when portion of XML loaded, so each time when branch loaded from XML event triggered and call tree.openItemsDynamic, which need to be called only once.Second part of issue caused by existing openItemsDynamic method which failed when different openItemsDynamic call executed while previous not finished yet. Some check was added to prevent an error - fixed js file sent by email
Even with the fixed file, the problem persists.
Please provide an example of how we should do this.
Which one of these should we be using?
tree.attachEvent(“onXLE”,function() {
tree.openItemsDynamic(“2,95,94,4”);
});
-or-
tree.loadXML("’.$url.’",function(){
tree.openItemsDynamic(“2,95,94,4”);
});
We are using the first one with the file you sent, and the issue persists.
Please use the second approach.