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
Lazy DataTable Client side clearFilters()
-
- Posts: 71
- Joined: 21 Feb 2011, 18:37
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
}
/**
* 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
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 29 guests