Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I filter a p:tree

I built a tree using Primefaces JSF and I need to add a filter, where it update the data of the tree according to what the user typed. Does anyone know if this is possible ? I still can not find a solution.

Tree: http://www.primefaces.org/showcase/ui/data/tree/basic.xhtml

like image 571
Débora Cristina Avatar asked Jan 22 '26 12:01

Débora Cristina


2 Answers

Primefaces Tree support filters since Primefaces 6.1

<p:tree value="#{treeBasicView.root}" filterBy="#{node}" var="node">
   <p:treeNode>
       <h:outputText value="#{node}" />
    </p:treeNode>
</p:tree>

https://www.primefaces.org/primefaces-6-1-final-released/

For older versions, see the other answer.

like image 63
meyquel Avatar answered Jan 25 '26 11:01

meyquel


Before PrimeFaces 6.1 this was not possible IN the tree. On older versions just create an input field outside the tree and update the tree after calling a bean that server side updates the data for the tree based on the value of the input field.

like image 36
Kukeltje Avatar answered Jan 25 '26 11:01

Kukeltje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!