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

45Re: [ydn-javascript] Re: how to make leaf nodes with TreeView.setDynamicLoad()

Expand Messages
  • Eric Miraglia
    Feb 14, 2006
    • 0 Attachment

      A TextNode with no children, one on which you haven't invoked setDynamicLoad, won't display the [+].  Once a TextNode is set to load dynamically, the expand icon does persist (even when the node turns out to be childless).  This was actually an interaction design decision -- this solution either tested better or seemed more intuitive to the designers.

      It appears that you can change the behavior pretty easily by subclassing whichever node class you're using and then overriding the getStyle method in that subclass.  Look at the getStyle method in Node.js for a baseline; start with that method:

         getStyle: function() {
              if (this.isLoading) {
                  this.logger.debug("returning the loading icon");
                  return "ygtvloading";
              } else {
                  // location top or bottom, middle nodes also get the top style
                  var loc = (this.nextSibling) ? "t" : "l";

                  // type p=plus(expand), m=minus(collapase), n=none(no children)
                  var type = "n";
                  if (this.hasChildren(true) || this.isDynamic()) {
                      type = (this.expanded) ? "m" : "p";

                  this.logger.debug("ygtv" + loc + type);
                  return "ygtv" + loc + type;

      Check out the line that reads  if (this.hasChildren(true) || this.isDynamic()) {; remove the conditional on this.isDynamic(), so that it evaluates only based on hasChildren().  That should get you the result you're looking for, if I understand your needs correctly.

      Good luck...let us know how it goes.


      On Feb 14, 2006, at 4:48 PM, ggederer wrote:


      Thanks for the response.  The workaround you suggest is pretty good
      except that empty nodes that can have children (like empty folders in
      a file browser) render as if they, in fact, had children (little plus
      sign next to the folder.)

      Just glancing at the sources, it looks like it would be fairly easy to
      implement something like setCanHaveChildren().  Is this the approach
      you are considering?  I may just do this or something similar for my
      own needs.  If I do, I would be happy to send you the diffs.

      I like your library.



      --- In ydn-javascript@yahoogroups.com, Eric Miraglia <miraglia@...> wrote:


      There's no way currently to indicate that a specific child has no  
      children of its own.  This is something we see a need for, but we  
      don't have it yet.

      One workaround for this is to use the setDynamicLoad method at the  
      node level rather than at the tree level.  Invoke that method for all  
      nodes that either have or might have children; for those you know  
      won't have children, just skip that step.

      That will result in the behavior you're looking for, I think.


      On Feb 14, 2006, at 2:35 PM, ggederer wrote:


      I have got a dynamically loding tree working; but, all of the
      dynamically loaded nodes are expandable. How do I indicate that a
      dynamically loaded node has no children?

      Great library!



      Yahoo! Groups Links

      Yahoo! Groups Links

      <*> To visit your group on the web, go to:

      <*> To unsubscribe from this group, send an email to:

      <*> Your use of Yahoo! Groups is subject to:

    • Show all 10 messages in this topic