Loading ...
Sorry, an error occurred while loading the content.

Dynamically (segmented) loading tree

Expand Messages
  • David Prusak
    Hello everyone, I ve been working on a little project to load a dynamic tree of what could contain thousands of nodes within a tree. I have the code working as
    Message 1 of 2 , Feb 18, 2006
    • 0 Attachment
      Hello everyone,

      I've been working on a little project to load a dynamic tree of what
      could contain thousands of nodes within a tree.

      I have the code working as it loads and updates 15 nodes at a time.

      However, I'm a little puzzled on the onCompleteCallback function. I
      can't seem to find any documentation on this function or where to
      find it. (For some reason, when I grep the js directory, it cannot
      be found, so I assume it's a javascript built in function?)

      Anyway, the issue I have is that when I call the onCompleteCallBack,
      the page will render my updates, but it turns off the nice little
      animated loading icon.

      I've tried to a few things.

      if (nodeComplete != 0){
      startNum = startNum + 15;
      loadDataForNode(node, onCompleteCallback, startNum);
      } else {
      onCompleteCallback();
      }

      What this does is loads the entire tree without updating the UI
      until all the nodes are complete.

      Here is my code snippit below:

      function loadDataForNode(node, onCompleteCallback, startNum){
      if (!startNum) startNum=1;
      var pathTo = node.data.pathTo;

      var responseSuccess = function(o){
      var path;
      var dirs;
      var files;

      var myNode = o.responseText.split("##");
      var nodeComplete = myNode[1]
      var myTree = myNode[0].split("&&");

      for ( var i = 0; i < myTree.length; i++ ) {
      var myNodeInfo = myTree[i].split("||");
      myData = new Object ();
      myData.name = myNodeInfo[0];
      myData.initialState = 1;
      myData.currentState = 0;
      myData.hasChanged = 0;
      myData.size = "myNodesInfo[3]";
      myData.pathTo = myNodeInfo[1];
      myData.mimeType = myNodeInfo[2];

      if (myNodeInfo[0] != ''){
      treeChildren = new YAHOO.widget.TaskNode(myData,
      node, false);
      if (myData.mimeType == "File Folder" ||
      myData.mimeType == ""){
      treeChildren.setDynamicLoad(loadDataForNode);
      }
      }

      }
      tree.draw();
      if (nodeComplete != 0){
      startNum = startNum + 15;
      loadDataForNode(node, onCompleteCallback, startNum);
      }
      }

      var responseFailure = function(o){ alert('responseFailure: ' +
      o.statusText); }
      var callback = {
      success:responseSuccess,
      failure:responseFailure
      };
      var cObj = YAHOO.util.Connect.asyncRequest
      ('POST','someURLThatReturnsVariousDelimitedString,callback,'action=li
      st&path='+pathTo);

      // Be sure to notify the TreeView component when the data load
      is complete
      onCompleteCallback();
      }
      }

      Any suggestions?
      --David
    • Adam Moore
      ... Hi David, Native support for segmented loading would be very useful. The feature is being considered for a future release. -Adam
      Message 2 of 2 , Feb 23, 2006
      • 0 Attachment
        On Sat, Feb 18, 2006 at 10:29:39PM -0000, David Prusak wrote:
        > Hello everyone,
        >
        > I've been working on a little project to load a dynamic tree of what
        > could contain thousands of nodes within a tree.
        >
        > I have the code working as it loads and updates 15 nodes at a time.

        Hi David,

        Native support for segmented loading would be very useful. The feature
        is being considered for a future release.


        -Adam
      Your message has been successfully submitted and would be delivered to recipients shortly.