Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Don on Jul 03, 2008 09:25
open dhtmlx forum
openItemsDynamic

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.
Answer posted by Stanislav on Jul 05, 2008 05:31
>>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");
Answer posted on Feb 21, 2009 20:36
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.


Answer posted on Feb 21, 2009 21:02
It actually happens in Firefox as well... says this:

too much recursion
dhtmlx/tree/dhtmlxtree_xw.js
Line 23
Answer posted by Support on Feb 23, 2009 07:35
>>too much recursion
Situation 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 tree

If 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 )
Answer posted on Feb 24, 2009 14:37
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. 
Answer posted on Feb 24, 2009 14:40
Answer posted on Feb 24, 2009 15:12
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?


Answer posted by Support on Feb 25, 2009 05:55
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


Answer posted on Apr 20, 2009 20:44
Even with the fixed file, the problem persists.
Answer posted on Apr 20, 2009 20:46
Please provide an example of how we should do this.
Answer posted on Apr 20, 2009 20:48
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.
Answer posted by Alex (support) on Apr 21, 2009 03:16
Please use the second approach.