0

How to implement a "Clear All Selection" button which will uncheck all selected things from a TreeTable implemented using PrimeFaces 6.2

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Shubha
  • 3
  • 2

1 Answers1

1

I would use the client side API for this. It allows you to unselectAllNodes. You can use it in combination with the widgetVar of your tree table:

PF('yourWidgetVar').unselectAllNodes()

In a button, use it like:

<p:button value="Clear selection"
          onclick="PF('yourWidgetVar').unselectAllNodes();return false"/>

Note that the linked documentation applies to the latest release, but the unselectAllNodes function is also present in 6.2: https://github.com/primefaces/primefaces/blob/6_2/src/main/resources/META-INF/resources/primefaces/treetable/treetable.js#L701-L709

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • I used this way to implement the above unselectall Took the method from documentation tried declaring that in my xhtml code and calling it but wasnt working. https://www.logicbig.com/tutorials/misc/primefaces/request-context-execute.html – Shubha Apr 28 '22 at 07:13