DataTable clearFilter() not working properly

前端 未结 4 903
失恋的感觉
失恋的感觉 2021-02-02 14:33

I have a complicate JSF that contain dataTable with filter in each one of the columns. In order to make sure that the generate button will fetch all the data first I need to cle

4条回答
  •  醉酒成梦
    2021-02-02 14:54

    For Primefaces 7 and above, use the following:

    public void clearAllFilters() {
    
        DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:dataTable");
        if (!dataTable.getFilters().isEmpty()) {
            dataTable.reset();
    
            PrimeFaces.current().ajax().update("form:dataTable");
        }
    }
    

提交回复
热议问题