Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ag grid : js : How to find which filter is applied

Tags:

ag-grid

I have data displayed in ag grid. It has 4 columns name,age,sport and has the following data:-

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

like image 875
Ashish Avatar asked Dec 14 '22 15:12

Ashish


2 Answers

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

like image 107
Paritosh Avatar answered Dec 28 '22 05:12

Paritosh


Starting from [email protected] to get or set all applied filters you can take advantage of using:

const savedModel = gridApi.getFilterModel();
gridApi.setFilterModel(savedModel);
like image 27
nakhodkin Avatar answered Dec 28 '22 06:12

nakhodkin