1
votes

I have a custom agGrid filter component which has a text box and a checkbox list with distict values in that column. The custom gridFilter component works as expecrted and re renders the result based on the selection changes made to the filter. I have a requirement to re-render the selected values in the column filters on page - refresh . This should also trigger the grid to re- render based on the filter selection. I have a custom setModel method which updates the filters upon refresh , but this change does not trigger the grid to reload based on the selected filters. Please let me know if there is a way to trigger the grid reload based on the selected filters on refresh.

1

1 Answers

0
votes

You must call gridApi.onFilterChanged() after setting the filter model.

From the documentation: (https://www.ag-grid.com/javascript-grid-filter-api/)

"After filters have been changed via their API, you must ensure the method gridApi.onFilterChanged() is called to tell the grid to filter the rows again. If gridApi.onFilterChanged() is not called, the grid will still show the data relevant to the filters before they were updated through the API.

// Get a reference to the filter instance
var filterInstance = gridApi.getFilterInstance('name');

// Set the filter model
filterInstance.setModel({
    filterType: 'text',
    type: 'startsWith',
    filter: 'abc'
});

// Tell grid to run filter operation again
gridApi.onFilterChanged();

"