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

how to dynamically load treeview ROOT node?

Expand Messages
  • thirteenth_monster
    Is there a way to dynamically load the initial children that are appended to the root node? I have seen other posts about dynamic loading, and they have
    Message 1 of 2 , Jun 1, 2006
    View Source
    • 0 Attachment
      Is there a way to dynamically load the initial children that are
      appended to the root node? I have seen other posts about dynamic
      loading, and they have referenced this example;

      http://com1.devnet.scd.yahoo.com/yui/examples/treeview/dynamic.html?mode=dis

      But in the example there are 5 nodes that are explicitly appended to
      the root node. All the dynamic loading happens afterwards on those
      children. After the first nodes are there, you can trigger the dynamic
      load by clicking on the [+] expand links, but prior to there being any
      children, there does not appear to be a way to trigger the dynamic
      load. There's no tree.getRoot().load() method. The expand(),
      showChildren() & toggle() methods don't seem to do it.

      I've tried explicitly calling the dynamic load method like so;

      tree = new YAHOO.widget.TreeView("tree1");
      tree.setDynamicLoad(loadDataForNode);

      loadDataForNode(tree.getRoot(), tree.getRoot().loadComplete);

      I think this should work, but when it calls into the loadComplete
      function in treeview.js, the reference to the node is messed up- it
      seems to think it's a Window object instead of a node.

      Help?
    • Adam Moore
      ... Manually calling the data load function as you have done won t work because the execution scope isn t what is expected. Also, the loadComplete function
      Message 2 of 2 , Jun 1, 2006
      View Source
      • 0 Attachment
        On Thu, Jun 01, 2006 at 09:34:37PM -0000, thirteenth_monster wrote:
        >
        > Is there a way to dynamically load the initial children that are
        > appended to the root node? I have seen other posts about dynamic
        > loading, and they have referenced this example;
        >
        > http://com1.devnet.scd.yahoo.com/yui/examples/treeview/dynamic.html?mode=dis
        >
        > But in the example there are 5 nodes that are explicitly appended to
        > the root node. All the dynamic loading happens afterwards on those
        > children. After the first nodes are there, you can trigger the dynamic
        > load by clicking on the [+] expand links, but prior to there being any
        > children, there does not appear to be a way to trigger the dynamic
        > load. There's no tree.getRoot().load() method. The expand(),
        > showChildren() & toggle() methods don't seem to do it.
        >
        > I've tried explicitly calling the dynamic load method like so;
        >
        > tree = new YAHOO.widget.TreeView("tree1");
        > tree.setDynamicLoad(loadDataForNode);
        >
        > loadDataForNode(tree.getRoot(), tree.getRoot().loadComplete);
        >
        > I think this should work, but when it calls into the loadComplete
        > function in treeview.js, the reference to the node is messed up- it
        > seems to think it's a Window object instead of a node.

        Manually calling the data load function as you have done won't work because
        the execution scope isn't what is expected. Also, the loadComplete function
        does not work properly for the root node. The latter is something that will
        be fixed in a future release. For now, try the following to get your code to
        work:

        loadDataForNode(tree.getRoot(), function() { tree.draw() });


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