3
votes

While using custom filter options in a grid column I encountered the need to compare the cellValue with some other value of the same row and can't seem to find how to do so, given that no reference to the row data is passed to the test function.

columnDefs: [
{
    field: "Column 1",
    (...)
    filterParams: {
        filterOptions: [
            'lessThan',
            'greaterThan',
            {
                displayKey: 'lessThanColumn2',
                displayName: 'Less Than column 2',
                test: function(filterValue, cellValue) {
                    return cellValue < rowData.column2; // <------ how?
                }
            },
    }
}
(...)
]

Using a valueGetter to include all needed data in the cell value and displaying only the relevant part using a Cell Renderer seems to be a workaround.

Is it possible to achieve this in any other way without a custom filter?

1
I think custom filter suits better for row level filtering. What you can do is define a custom filter satisfies your needs and trigger it from the column test fubctionEldar

1 Answers

0
votes

ColDef also has possibility to define filterValueGetter, you can try to do something like this:

filterValueGetter: (params: ValueGetterParams) => {
    const rowData = params.data.$sourceDataItem;
    return rowData; // pass all row data
},

I guess the filterValue in your test function will now contain row data.