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

Re: Any Ways to Disable Dynamic Load for Non-Root Nodes?

Expand Messages
  • Chun
    There is a work-around I ve tried: Instead of setting the root dynamic, as shown by the Yahoo tutorial and example, set the node dynamic when you re creating
    Message 1 of 4 , Apr 3, 2006
    • 0 Attachment
      There is a work-around I've tried: Instead of setting the root
      dynamic, as shown by the Yahoo tutorial and example, set the node
      dynamic when you're creating EACH node. Of course, when you have ways
      to know in advance that a particular node is leaf, don't set it as
      dynamic. This will make the leaf nodes appear without expandable
      and/or folder icons.
    • dprusak@pacbell.net
      ... node ... expandable node. ... returns ... does ... I m not sure if I follow. We use treeview and we can set dynamic on/off when needed and it works for
      Message 2 of 4 , Apr 3, 2006
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Chun" <chunpan.geo@...>
        wrote:
        >
        > I have created a folder tree view and set the root as dynamically
        > loaded. It all works fine. The only problem is that when a leaf
        node
        > is reached, since it doesn't know if the node contains any children
        > before it is expanded, the leaf node also shows up as an
        expandable node.
        >
        > I have looked at the source code, the Node.isDynamic() method
        returns
        > the following:
        >
        > (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad))
        >
        > It is very clear that once the root is set to dynamic (_dynLoad is
        > true), there is no effect to turn it off on a child Node, as
        > isDynamic() will always return true for any non-root Nodes.
        >
        > In my situation, I have a way to know if the Node I'm creating has
        > children or not (via my own AJAX function), but the TreeView API
        does
        > not support overriding _dynLoad property on a child Node.
        >
        > So here is my suggestion to refactor treeview.js:
        > (1) Modify Node.isDynamic() method. Make it return just the Node's
        > _dynLoad property.
        > (2) In the Node's constructor, set _dynLoad automatically based on
        > Root's _dynLoad property. Thus all child Nodes from a dynamic Root
        > will be dynamic by default, UNLESS you turn it off.
        >
        > I would like to know if anyone else has run into similar problems
        > before and how much you agree with my suggestion. Thanks!
        >

        I'm not sure if I follow. We use treeview and we can set dynamic
        on/off when needed and it works for us.

        When we expand the tree and the data coming in lets us know what's a
        directory or a file (dynamic node on or off).

        if (myData.name.length > 0) {
        child = new YAHOO.widget.TaskNode(myData, node, false);
        if (myData.mimeType == "File Folder"
        child.setDynamicLoad(loadDataForNode);
        }
        }

        I guess I don't really understand the question :)

        --David
      • Chun
        Thanks, David, for trying to help. I soon replied to my own message with the solution similar to yours. I guess my original question was about the level on
        Message 3 of 4 , Apr 10, 2006
        • 0 Attachment
          Thanks, David, for trying to help. I soon replied to my own message
          with the solution similar to yours. I guess my original question was
          about the level on which "setDynamicLoad()" is set. There is no
          problem for me to set it when building each child node, but if I set
          it on the whole tree level (just for convenience), I wouldn't be able
          to turn it off on a child node. It seems to be the way that TreeView
          is designed, and I guess I just have to use it like what you did. :)

          Thanks again,
          Chun

          --- In ydn-javascript@yahoogroups.com, "dprusak@..." <dprusak@...> wrote:
          >
          > I'm not sure if I follow. We use treeview and we can set dynamic
          > on/off when needed and it works for us.
          >
          > When we expand the tree and the data coming in lets us know what's a
          > directory or a file (dynamic node on or off).
          >
          > if (myData.name.length > 0) {
          > child = new YAHOO.widget.TaskNode(myData, node, false);
          > if (myData.mimeType == "File Folder"
          > child.setDynamicLoad(loadDataForNode);
          > }
          > }
          >
          > I guess I don't really understand the question :)
          >
          > --David
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.