How to reset a data filter by table through the server side

In my main jsf there are 2 jsfs where in each of them there is a table with a filter parameter.

This is a short example from the main:

<h:panelGroup id="b1"> <p:commandButton value="exe" actionListener="#{bean.handle}" rendered="#{bean.render}" update=":mainForm:panel1,:mainForm:panel2"> </p:commandButton> </h:panelGroup> </h:panelGrid> </p:panel> <ui:include src="table1.xhtml" /> <ui:include src="table2.xhtml" /> 

The problem is that I need to remove filters when changing the view between two tables. I cannot use the client side via clearFilters, since I have two tables:

 <p:commandButton oncomplete="table1Widget.clearFilters() ????" 

so I thought the best place would be on the server side using the handle method, but the filter list is empty as well as the table

 DataTable dt1 = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("mainForm: .... "); 

How can I reset filter?

thanks

+4
source share
3 answers

I have 2 data types in my session. I did not understand the reasons, but when I use dt1.reset() , it resets both of them.

I tried

 dt1 = new DataTable(); 

and he solved my problem.

Note: dt1.reset() works when I tried with 1 datatable.

+1
source

You can use any of the following actions in this datatable that you have:

  • dt1..setFilters(null); Get rid of datatable filter values

  • dt1.reset() will also reset to its original state

0
source

Use the current Primefaces helper (version 6.2) to run server side clearFilters, as shown below:

 PrimeFaces current = PrimeFaces.current(); current.executeScript("PF('dataTableWidget').clearFilters()"); 
0
source

All Articles