koolhuman
koolhuman

Reputation: 1651

Property 'resetFilterValues' does not exist on type 'IFilterComp'

I am trying to reset the filters after new data is being loaded to resolve the 'select all' issue but i get the below error when using resetFilterValues() function. Not sure what could be the issue. I have been seeing the documents and it looks like the function is correct but when i go to the definition of IFilterComp there is no function "resetFilterValues()"

"error TS2339: Property 'resetFilterValues' does not exist on type 'IFilterComp'."

I am using the latest version of ag-grid 21.1.0 and angular framework.

  var columns = this.gridOptions.columnApi.getAllColumns();
  columns.forEach(col => {
    var filter = self.gridOptions.api.getFilterInstance(col.getColId());
    if (filter.isFilterActive()) {
      var filterModel = filter.getModel();
      filter.resetFilterValues();
      filter.setModel(filterModel);
    }
    else {
      filter.resetFilterValues();
    }
  });

plunker - http://plnkr.co/edit/yb8tHVIJpz6MVytS3Vb8?p=preview

Please check in the console log after clicking "Reset Filter" button. I am using gridOptions api call because all the components/functions/api are tied to gridOptions.

Upvotes: 0

Views: 2095

Answers (1)

Pratik Bhat
Pratik Bhat

Reputation: 7614

Th reason this line throws an error is because resetFilterValues() is a set filter api as described here and it won't work for filters of other types.

The other way of resetting all filters would be to use this api function as shown in example

clearFilters() {
        this.gridApi.setFilterModel(null);
        this.gridApi.onFilterChanged(); 
}

Upvotes: 1

Related Questions