Clear af:table filter programmatically , reset table filter in 12C (ADF)

Sharing is Caring

Sometimes we need to clear af:table filter on some event in ADF application. So for that there is a code to reset or clear af:table filter. Previously I have posted about clearing table filter using row header column.

Here searchTabBind is the component binding of af:table created in the managed bean

    /**
     * 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

Cheers 🙂 Happy Learning

Related Posts

7 thoughts on “Clear af:table filter programmatically , reset table filter in 12C (ADF)”

  1. Hi Ashish,

    Many 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

  2. That's the default behavior when filter is not applied then table should show all the data
    If you don't want to show any data after clearing filter then try putting some condition or criteria on viewObject

  3. Hi Ashish,
    Am populating the table value depends upon the 2 boolean property ( Ex : value=”#{(pageFlowScope.xxxxBean.xxxx || pageFlowScope.xxxxBean.xxxx)?bindings.xxxxRange.collectionModel:bindings.yyyyRangeFiltered.collectionModel}”) . For this table am trying to add filter but am facing problem because of this 2 different binding. Could you help me on this…

Leave a Reply

Your email address will not be published. Required fields are marked *