0
votes

I'm trying to follow the official example on AgGrid's website: https://www.ag-grid.com/javascript-grid-filter-api/#example-filter-api

Using v20.1 I am not able to applyFilter, how

  const myFilterInstance = api.getFilterInstance('my_field');
  if (myFilterInstance ) {
    myFilterInstance .setModel({
      type: 'equals',
      filter: 'blah'
    });
    (myFilterInstance as any).applyModel();
    api.onFilterChanged();
  }

It looks like v20.1 definition of AgGrid don't have applyModel? What's the correct way to change the filter dynamically in v20?

1

1 Answers

2
votes

You don't need to call applyModel if you ae doing setModel. Simply call api.onFilterChanged.

  sportStartsWithS() {
    var sportsFilterComponent = this.gridApi.getFilterInstance("sport");
    sportsFilterComponent.setModel({
      type: "startsWith",
      filter: "s"
    });
    this.gridApi.onFilterChanged();
  }

Reference: https://www.ag-grid.com/javascript-grid-filter-api/#example-filter-api (The same link)