I am using ag-grid with angular and I want to apply an external filter to it.
The documentation shows an example what the doesExternalFilterPass
function can look like:
function doesExternalFilterPass(node) {
switch (ageType) {
case 'below30': return node.data.age < 30;
...
default: return true;
}
}
It basically uses the raw data to filter the rows. As I use the columns valueGetter/filterValueGetter functions to modify the values, I want the external filter to filter based on the return values of these functions but I haven't found the proper way to do this.
I can get the value that I want by calling
this.gridOptions.api.getValue(columnId, node);
(which calls the valueGetter under the hood) instead of
node.data[columnId]
but I didn't find any example doing it that way.
So I am asking for the right way of calling the valueGetter functions inside doesExternalFilterPass
or how anybody else approached this problem.
(It is especially important when you have rows that are not even included in the data object. This is the case when a columns values are calculated through a valueGetter/filterValueGetter function e.g. by adding two other columns.)
Instead of using a valueGetter
, you can add a custom field to your data model that you compute before feeding data to the grid. You will need to pre-process the data and then use this new field in column definition and external filter.