ag grid : js : 如何找到应用了哪个过滤器
ag grid : js : How to find which filter is applied
我在 ag 网格中显示了数据。
它有 4 列名称、年龄、运动并具有以下数据:-
data
现在当我根据 "sport" 过滤数据时,假设取消选中 "blanks"
我得到以下数据:-
filtered data
1)我的问题是如何获取对列应用了哪个过滤器,
就像在这种情况下 "blanks" 应用于 "sport".
2)如果我使用刷新数据
api.setRowdata(),应用于列的过滤器丢失
1.how to get the which filter is applied on columns
您可以使用 gridApi.filterManager.allFilters
获取它
检查这个实例 ag-grid: Built-In Filters - log the filters applied。
应用 age
和 year
过滤器,然后单击 Log Filter
按钮。
age: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
year: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
__proto__: Object
对于
- if I refresh the data using
api.setRowdata()
, filter applied to the columns are lost
我们可以对 columnDefs
对象中的列使用以下设置:-
filterParams: {
newRowsAction: 'keep'
}
Starting from ag-grid@19.0.0
to get or set all applied filters you can take advantage using:
const savedModel = gridApi.getFilterModel();
gridApi.setFilterModel(savedModel);
我在 ag 网格中显示了数据。 它有 4 列名称、年龄、运动并具有以下数据:-
data
现在当我根据 "sport" 过滤数据时,假设取消选中 "blanks" 我得到以下数据:- filtered data
1)我的问题是如何获取对列应用了哪个过滤器, 就像在这种情况下 "blanks" 应用于 "sport".
2)如果我使用刷新数据 api.setRowdata(),应用于列的过滤器丢失
1.how to get the which filter is applied on columns
您可以使用 gridApi.filterManager.allFilters
检查这个实例 ag-grid: Built-In Filters - log the filters applied。
应用 age
和 year
过滤器,然后单击 Log Filter
按钮。
age: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
year: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}
__proto__: Object
对于
- if I refresh the data using
api.setRowdata()
, filter applied to the columns are lost
我们可以对 columnDefs
对象中的列使用以下设置:-
filterParams: {
newRowsAction: 'keep'
}
Starting from ag-grid@19.0.0
to get or set all applied filters you can take advantage using:
const savedModel = gridApi.getFilterModel();
gridApi.setFilterModel(savedModel);