Please disable your adblock and script blockers to view this page

Search this blog

Thursday, 24 April 2014

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

Code to reset or clear af:table filter- here searchTabBind is the binding of af:table




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

6 comments :

  1. Hi,

    Can you please elaborate what is getSearchTabBind ??

    Thanks,
    Vishal Kumar

    ReplyDelete
    Replies
    1. Hi Vishal

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

      Ashish

      Delete
  2. 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

    ReplyDelete
    Replies
    1. No need to use empty RowSet , just use above code and it'll reset table data n filter both

      Delete
  3. Hi Ashish,

    Its pulling up all the table results after clearing the filters.

    Thanks,
    Vishal Kumar

    ReplyDelete
    Replies
    1. 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

      Delete