cancel
Showing results for 
Search instead for 
Did you mean: 

Fully Expanding Tree Before Displaying

Former Member
0 Kudos

I am building a tree that displays a company's workarea heirarchy in the wdDoInit method of a view. I would like the tree to be displayed fully expanded.

I tried setting the expand = "true" attribute of the TreeNode, but to no avail, the tree still shows fully collapsed. Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Say you have the following context structure:


TreeNodes (node, 0:n)
-- expanded (boolean)
-- Children (recursive node -> TreeNodes)

and you have bound the "expanded" property of the TreeNodeType element to context attribute "TreeNodes.expanded".

To expand all tree nodes, recursively set the "expanded" attribute value to true:


void expandAll(ITreeNodesElement treeNode)
{
  treeNode.setExpanded(true);
  for (int i = 0; i < treeNode.nodeChildren().size(); ++i)
  {
    ITreeNodesElement child = treeNode.nodeChildren().getTreeNodesElementAt(i);
    expandAll(child);
  }
}

wdDoInit()
{
  /* assume we have at most one root */
  if (wdContext.nodeTreeNodes().size() > 0)
  {
   expandAll( wdContext.nodeTreeNodes().getTreeNodesElementt(0) );
  }
}

Armin

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try

Creating a context attribute of type boolean as part of the node which is bound to the tree by nesting table and set this attribute to true.

And bind this to the expanded property of tree by nesting UI element.

Regards

Ayyapparaj