Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by MDAweb on Nov 23, 2007 04:16
open dhtmlx forum
Loading Graphic on specific tree nodes (dhtmlxTree)

I would like to be able to show a 'refreshing' folder icon when I open a node with a lot of child nodes. I have worked out how to do a 'Loading' image whcih I can turn on/off via DIV style but this just sits over the whole tree - I would prefer to only update t he node icon that is actually waiting ofr data and then change it back when the data is loaded.

I have tried to acheive this using the OnOpenStart event handler, but it seems that using this overrides the setXMLAutoLoading paremeter so that it no longer directs to the specified URL when nodes are expanded. Instead, it just runs the code I have assigned to the event handler instead. Is there a way I can call my AutoLoading URL (in this case, an ASP file) from the event handler function instead?

Any help would be much appreciated!
Answer posted on Nov 23, 2007 05:50
Actually usage of onOpenStartevent must not affect default loading order, the next must work

tree.attachEvent("onOpenStart",function(id){
    //set temp icon
    return true; // if function not return true, operation will be stoped
});
tree.attachEvent("onOpenEnd",function(id){
    //restore normal icon
});


In common case you can call
    tree._loadDynXML(id);
to force loading xml for some item in question.
Answer posted by MDAweb on Nov 23, 2007 08:10

THanks for the reply...

I have tried your suggestion and I'm almost there. WHat I need to do is set the icon back after the CML has finished loading. I am attempting to do this as follows:


   tree.attachEvent("onOpenStart",function(nodeId){
    globalID = nodeId;
    tree.setItemImage2(nodeId,url);
    return true; // if function not return true, operation will be stoped
   });


   tree.attachEvent("onXLE",function(){
    var loadingDiv = document.getElementById('loading');
    loadingDiv.style.display= 'none';
    //alert(globalID);
    tree.setItemImage2(globalID,url2);
   });

 

I am setting 'globalID' to the nodeID within the onOpenStart event and wnating to use this to locate the same node and set the image back again within the onXLE function. It doesn't work though and doesn't give any errors. It just leaves the changed icon there rather than reverting back.

Answer posted by MDAweb on Nov 23, 2007 07:06

This is now working - problem with the URL paths for the images was making it appear as though it wasn't working correctly.