Categories | Question details Back To List | ||
TreeGrid change image on open/close Hello! I need to change image on branch opens and close. Is there are some event like OnOpen and OnClose? It is strange but this code doesnt work well: mygrid.attachEvent("onOpenStart",function(nodeId) { //this.setNodeIconOrWhatever(nodeId,"../controls/dhtmlxTreeGridPack/dhtmlxGrid/codebase/imgs/minus.gif"); mygrid.setItemImage(nodeId, "../images/tree/folderOpen.gif"); return true; // if function not return true, operation will be stoped }); mygrid.attachEvent("onOpenEnd",function(nodeId) { mygrid.setItemImage(nodeId, "../images/tree/folder.gif"); //restore normal icon //return true; }); it is seems that onOpenStart rised once on first open and fall when branch finished opens and image became old. And when branch opens it is seems that onOpenEnd rised that is why image became old. What is wrong with my code? Answer posted by Support on Mar 05, 2008 09:03 The order of event opening onOpenStart id,-1 onOpenEnd id,1 closing onOpenStart id,1 onOpenEnd id,-1 the both event fired for both opening and closing , current state may be checked by second event parameter mygrid.attachEvent("onOpenEnd",function(nodeId,mode) { if (mode==1) mygrid.setItemImage(nodeId, "../images/tree/folderOpen.gif"); else mygrid.setItemImage(nodeId, "../images/tree/folder.gif"); return true; }); Answer posted by Dmitry on Mar 05, 2008 20:24 Ok. Great Thanks!!! |