Skip to Content
author's profile photo Former Member
Former Member

Fully Expanding Tree Before Displaying

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 01:10 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 12:18 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.