Lazy DataTable Client side clearFilters()

UI Components for JSF
Post Reply
robert.m
Posts: 226
Joined: 07 Dec 2010, 22:52
Location: Salzburg/Austria

07 Apr 2011, 19:01

Hello everybody,

I'm successfully using a datatable with sorting, filtering, pagination with lazyloading.

I also have a commandButton which triggers the client-side function "clearFilters()" on the datatable-widgetVar.
While it works on a non-lazy table, it only clears the filter-input-textfields on a lazy one, but does not reset the filters on the server side.

I already tried to bind the dataTable to an Object in my backing bean, but this somehow completely messes up the layout of the dataTable.

Is there any other way for a filter-reset?

PF Version 2.2.1 and current 3.0-SNAPSHOT

Best regards,
Robert

luisalves00
Posts: 71
Joined: 21 Feb 2011, 18:37

23 Sep 2011, 13:17

public class PrimefacesUtil {

/**
* This method is an helper to clear the dataTable filters.
* @param facesContext current context
* @param tableId id of the table
*/
public static void resetFilters(FacesContext facesContext,String tableId) {
DataTable table = (DataTable) ComponentUtils.findComponent(facesContext.getViewRoot(), tableId);
if(table != null){
table.resetValue(); //enough when using lazy="false"
table.setFilters(new HashMap<String,String>()); //when using lazy="true" you need to explicitly clear the filters...
}
}

... you can implement more stuff

}

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests