I was using the
com.google.gwt.user.client.ui.Tree
widget where for a selectedTreeItem
I could easily check if it has any children:
Tree nodesTree = new Tree();
nodesTree.getSelectedItem().getChildCount()
Now I 开发者_开发知识库wanted to use the
com.smartgwt.client.widgets.tree.Tree
widget but I do not know how to find if a selected TreeNode
has any children. I'm a little confused on this...
A quick google says it's hasChildren(TreeNode node)
, which returns a boolean. See here.
EDIT: This checks if the node has any children (obviously). If you want to actually get the children, see Aaron's answer below. getChildren(TreeNode node)
returns an array of tree nodes. So if you wanted to see how many children it has, perhaps use getChildren(TreeNode node)
to get the array of children and then get the size of the array.
Looks like you can use...
getChildren(TreeNode node)
As viewed in the source
精彩评论