3 Replies Latest reply on Oct 15, 2009 12:06 PM by ahoehma

    Rich Tree Expand node

    mattc1


      We would like to be able to expand a node in a rich tree using javascript. Is there an example of this? Also is there a way to get the row key of a node in the tree via javascript?

        • 1. Re: Rich Tree Expand node
          ahoehma

          Hmmm ... I think this is (currently) not possible.

          For such client side code the whole tree have to stay on the client (switchType="client").

          Please describe more details. What do you want to do?

          • 2. Re: Rich Tree Expand node
            mattc1

            We have a tree with multiple node types. Some nodes we want to toggle on click but not select the node and other nodes we only want to toggle by clicking the arrow. Basically some nodes we want to behave as if the expand arrow is clicked when the node text is clicked.

            I came up with this script

            function setNodeToggle(e) {
             var elt = Event.element(e);
            
             var treeItem = Tree.Item.findComponent(elt);
             if (treeItem.isCollapsed())
             treeItem.expand();
             else
             treeItem.collapse();
            }


            That gets called by changing my rich:treeNode to

            <rich:treeNode type="contactfolder" onclick="setNodeToggle(event);" onselected="return false;">


            This appears to work. Does it look like a valid approach?

            -matt


            • 3. Re: Rich Tree Expand node
              ahoehma

              Looks good ... you can define different behaviors for different node-types.

              Have a look into my last blog about "customized rich tree"
              http://ahoehma.wordpress.com/2009/09/10/customized-richfaces-tree/

              Regards
              Andreas