Reputation: 243
I have data displayed in ag grid. It has 4 columns name,age,sport and has the following data:-
now when I filter the data based on "sport" , lets say uncheck "blanks" I get the following data:- filtered data
1)My questions is how to get the which filter is applied on columns , like in this case "blanks" is applied on "sport".
2)If I refresh the data using api.setRowdata(), filter applied to the columns are lost
Upvotes: 4
Views: 12333
Reputation: 1465
Starting from [email protected]
to get or set all applied filters you can take advantage of using:
const savedModel = gridApi.getFilterModel();
gridApi.setFilterModel(savedModel);
Upvotes: 7
Reputation: 243
For the
- if I refresh the data using
api.setRowdata()
, filter applied to the columns are lost
we can use the following settings for columns in columnDefs
object :-
filterParams: {
newRowsAction: 'keep'
}
Upvotes: 1
Reputation: 11560
1.how to get the which filter is applied on columns
You can get it using gridApi.filterManager.allFilters
Check this live example ag-grid: Built-In Filters - log the filters applied.
Apply age
and year
filters and then click Log Filter
button.
age: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
year: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
__proto__: Object
Upvotes: 7