Cjxcz Odjcayrwl
Cjxcz Odjcayrwl

Reputation: 22847

How to restore the state of p:dataTable before dialog reopen?

I'm using the PrimeFaces 3.5. I have p:dialog in which is p:dataTable. This is used to pick the item from filtered list.

After selecting the item I'm hiding the dialog and de-rendering the data table. But after showing the dialog again and re-rendering the data table, the data table contains the rows from previous filtering, but the filters themselves are clear.

I'm using the lazy data loading, so the values point to LazyDataModel, and the filteredValues are not set.

I would like to have the dataTable again in default state, so that both filters and selected rows would be empty. How to do that?

Upvotes: 1

Views: 1948

Answers (1)

kolossus
kolossus

Reputation: 20691

From the source, it looks like you can call reset() on an instance of org.primefaces.component.datatable.Table which will

  1. Clear filtered values
  2. Clear filters
  3. Reset it's value

So you should obtain a reference to the client side datatable (either by value binding or walking the DOM from event) and call table.reset()

Upvotes: 1

Related Questions