[ 3 posts ]

Paul

  • Username: paulg
  • Joined: Fri Oct 02, 2009 6:49 am
  • Posts: 76
  • Offline
  • Profile

TreeView: isLeaf is always false

Post Posted: Thu Mar 11, 2010 8:43 am
+0-
Hi,

I have a TreeView that I create by passing in JSON, along the lines of the static definition in this example: http://developer.yahoo.com/yui/examples ... arkup.html

The tree displays and works properly, yet every node has isLeaf set to false...including the leaves. Is there something I'm overlooking to get this to work right? Since the constructor created the tree (as opposed to me doing it node by node) I figured it would set the isLeaf property correctly. Do I need to do it manually?

Thanks,

Paul

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: TreeView: isLeaf is always false

Post Posted: Thu Mar 11, 2010 9:05 am
+0-
The isLeaf property is meant only for dynamic trees, not for static ones, where it is meaningless. In dynamically loaded trees, TreeView assumes that all nodes can be expanded and adds a plus sign to every node, assuming that it can be expanded into more nodes. Since the child nodes are to be loaded dynamically at some point, it is the most useful guess since it allows the visitor to keep diving into the branches and, at any rate, as part of the dynamic loading, the server might report that there are no further children that way.

However, when the child nodes are dynamically loaded, you can signal TreeView that a node is a leaf so no plus sign is placed in front of it and precluding any further diving into it.

Thus, isLeaf might be considered a write-only property to signal that a dynamically loaded node will have no children, it does not report on statically loaded nodes.

To find out about statically loaded nodes, check the length of the array of its children.

Paul

  • Username: paulg
  • Joined: Fri Oct 02, 2009 6:49 am
  • Posts: 76
  • Offline
  • Profile

Re: TreeView: isLeaf is always false

Post Posted: Thu Mar 11, 2010 9:47 am
+0-
Thanks...for another great answer!

Paul
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum