After upgrading AG Grid from version 33 to 34, I noticed a change in the behavior of the agSetColumnFilter
.
Setup:
Column filter: agSetColumnFilter
Config option: defaultToNothingSelected: true
Observed behavior:
When I open the filter and click "Select all", the filter becomes inactive (both with client-side and server-side row models).
In v33, this action would still filter out rows where the column value was empty or NULL
.
In v34, those empty/NULL
rows are now included instead.
Expected behavior (based on v33):
Clicking "Select all" should still exclude rows with empty/NULL
values.
Example:
https://stackblitz.com/edit/vitejs-vite-bvct5hqp?file=src%2FGridExample.jsx
import { useState } from 'react';
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
import { AllEnterpriseModule } from 'ag-grid-enterprise';
import { AgGridReact } from 'ag-grid-react';
ModuleRegistry.registerModules([AllCommunityModule, AllEnterpriseModule]);
export const GridExample = () => {
const [rowData, setRowData] = useState([
{ id: '1', category: 'A' },
{ id: '2', category: 'B' },
{ id: '3', category: 'C' },
{ id: '4', category: 'D' },
{ id: '5', category: null },
]);
const [colDefs, setColDefs] = useState([
{ field: 'id', width: 100 },
{
field: 'category',
flex: 1,
filter: true,
filterParams: {
defaultToNothingSelected: true,
values: ['A', 'B', 'C'],
},
},
]);
return (
<div style={{ width: '100%', height: '100%' }}>
<AgGridReact
rowData={rowData}
columnDefs={colDefs}
domLayout="autoHeight"
/>
</div>
);
};
Question:
Is this an intentional change in v34?
If so, is there any configuration or workaround to restore the old behavior (exclude empty/NULL
rows when using "Select all")?
Or should this be considered a bug?
I am having the same issue and apparently you can add suppressClearModelOnRefreshValues: true
to filterParams
to fix it.
Fun fact: it works for you but not for me 😅