I'd like to reset the filter, sort and paging state of an PrimeFaces DataTable. Unfortunately, there is no easy way to do so. Especially reseting the sort state is difficult.
What I did until now is:
DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(componentId);
if (dataTable != null) {
dataTable.setSortOrder("ascending"); // reset sortOrder
dataTable.setFirst(0); // reset page
dataTable.setFilteredValue(null); // reset filter
dataTable.setFilters(null);
}
I'm using PrimeFaces 3.4.1.