Code to reset or clear af:table filter- here searchTabBind is the binding of af:table
use this method on any button or link to clear af:table filter
/** * method to reset filter attributes on an af:table * @param actionEvent event which triggers the method */ public void resetTableFilterAction(ActionEvent actionEvent) { FilterableQueryDescriptor queryDescriptor = (FilterableQueryDescriptor) getSearchTabBind().getFilterModel(); if (queryDescriptor != null && queryDescriptor.getFilterConjunctionCriterion() != null) { ConjunctionCriterion cc = queryDescriptor.getFilterConjunctionCriterion(); List<Criterion> lc = cc.getCriterionList(); for (Criterion c : lc) { if (c instanceof AttributeCriterion) { AttributeCriterion ac = (AttributeCriterion) c; ac.setValue(null); } } getSearchTabBind().queueEvent(new QueryEvent(getSearchTabBind(), queryDescriptor)); } }
use this method on any button or link to clear af:table filter
Hi,
ReplyDeleteCan you please elaborate what is getSearchTabBind ??
Thanks,
Vishal Kumar
Hi Vishal
DeleteHere searchTabBind is the component binding of af:table that is created in managed bean
Ashish
Hi Ashish,
ReplyDeleteMany Thanks!! I could clear the filters. My requirement is to clear filters applied and clear rows at a time. I tried to execute empty rows after clearing the filters and its not working as expected. Can you help me on this.
Thanks,
Vishal Kumar
No need to use empty RowSet , just use above code and it'll reset table data n filter both
DeleteHi Ashish,
ReplyDeleteIts pulling up all the table results after clearing the filters.
Thanks,
Vishal Kumar
That's the default behavior when filter is not applied then table should show all the data
DeleteIf you don't want to show any data after clearing filter then try putting some condition or criteria on viewObject