onOpenEnd not fired on close - contrary to API

Hi,

The API says “onOpenEnd: Event raised immideatly after item in tree got command to open/close…”, but apparently it is only raised in case I open a node. Is that possible? Any workaround?

Thanks in advance

Event must work for both item opening and item closing.
Please beware, that in case of dynamical loading, if you open multiple items at once ( with multiple separate calls to server ) - the event may fire not for all of opened items.

If problem still occurs for you - please provide any kind of sample - you can send it directly to support@dhtmlx.com

OK, we’re both right :slight_smile: the event is fired after usual opening/closing, but it’s never fired if I open/close the tree with tree.openItem(id)/tree.closeItem(id)

…which is annoying if you don’t want to have node icons and plus/minus-icons, so you disable the plus/minus icons and therefore have to use the open() function within the click event

The original idea was to fire event when it caused by user, and not call it, when it caused by grid API
You can modify tree code and add event to API calls

dhtmlXTreeObject.prototype.openItem=function(itemId){
      var temp=this._globalIdStorageFind(itemId);
      if (!temp) return 0;
      else return this._openItem(temp);
      this.callEvent(“onOpenEnd”,[itemId,this.getOpenState(itemId)]);   //this will add event call to tree.openItem
   };

OK, my final (?) 2 cents:

>> if (!temp) return 0;
>> else return this._openItem(temp);
>> this.callEvent(“onOpenEnd”,[itemId,this.getOpenState(itemId)]);   //this will add event call to tree.openItem

the last line is never called - as it’s after the return statement
Anyway: My last post was misleading, but as I wrote in the first post, the closing-a-node is the problem, so I added your line to the following function:

   dhtmlXTreeObject.prototype.closeItem=function(itemId){
      this.callEvent(“onOpenEnd”,[itemId,this.getOpenState(itemId)]);   //this will add event call to tree.openItem
      if (this.rootId==itemId) return 0;
      var temp=this._globalIdStorageFind(itemId);
      if (!temp) return 0;
         if (temp.closeble)
            this._HideShow(temp,1);
   };
  
Thanks

the last line is never called - as it’s after the return statement
agree, was a typo from my side