sarfaraz ahmed
sarfaraz ahmed

Reputation: 175

default tree node expanded in p:tree not working

By default tree node expanded in PrimeFaces not working. Here is XHTML:

<p:tree value="#{marketMappinBean.root}" 
        selectionMode="checkbox"
        selection="#{marketMappinBean.selectedNode}"
        var="node" id="treeNode"  animate="true" highlight="true" style="width: auto "
>

<p:treeNode>
    <h:outputText value="#{node.name}" />
</p:treeNode>

Here is java class code:

root = db.getSelectedEmployeeMarketsTree(userID);
root.setExpanded(true);

I want that when I click on the button by default tree node should be expanded. and it is showing on next page,until now it is showing on next page but not expanded

Upvotes: 1

Views: 805

Answers (1)

Hicham
Hicham

Reputation: 170

To be expanded, the setExpanded should be applied to the node and not to the root:

TreeNode node = new DefaultTreeNode("Text", root);

node.setExpanded(true);

Upvotes: 1

Related Questions