Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column filter for "empty" value

Tags:

ag-grid

Is there a way to add a column filter for empty values? I see we can filter for equal, not equal, ... but I'd like to have an option to filter a column so it returns rows where the column is empty or null.

like image 926
vmasanas Avatar asked Jun 21 '26 19:06

vmasanas


1 Answers

I had the same issue with empty cells You should use 'Blank option'

const filterOptions = [
    'empty',
    {
        displayKey: 'blanks',
        displayName: 'Blanks',
        test: function (filterValue, cellValue) {
            return cellValue == undefined;
        },
        hideFilterInput: true,
    },
    'equals',
    'notEqual',
    'lessThan',
    'lessThanOrEqual',
    'greaterThan',
    'greaterThanOrEqual',
    'inRange'
];

columnDef = [
    {
        headerName: 'someValue', field: 'someValue',
        filter: 'agNumberColumnFilter',
        filterParams: {
            filterOptions: filterOptions
        }
    },]

'empty' - is equal to 'Please choose option'

more inforamtion you can find here: https://www.ag-grid.com/javascript-grid-filter-provided-simple/#blank-cells-date-and-number-filters

like image 152
shutsman Avatar answered Jun 24 '26 17:06

shutsman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!