'Ag-grid: Is there a way to add a custom filter to default filters

I'm trying to add a custom filter of using string similarity algorithm to the default text filters. Is there any way to do it?

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      columnDefs: [
        {
          headerName: "Make",
          field: "make",
          sortable: true,
          filter: true,
          checkboxSelection: true,
        },
        ...
      ],
       ...
    }
  }
}

In the code above, if I give true for the filter of Make column, the full list of default text filters are presented. But if I add filterParams.filterOptions as below

...
this.state = {
  columnDefs: [
    {
       headerName: "Make",
       field: "make",
       sortable: true,
       filter: "agTextColumnFilter", 
       filterParams: {
         filterOptions: [
           "similarTo",
           {
              displayKey: "similarTo",
              displayName: "similar to",
              test: function (filterValue, cellValue) {
                           ...
                   return stringSimilarity > 0.8;
              }
            }
            ...]
         }
      }
      ... ]
}

Only "similarTo" filter is on the list of filters. Is there any way to add this custom filter to the default text filters, including contains, not contains, equals, not equals, starts with, and ends with.



Solution 1:[1]

Ag grid comes up with a solution to add custom filters.

These documents are enough to understand how we can implement them.

DocumentLink : https://ag-grid.com/react-data-grid/filter-provided-simple/#custom-filter-options

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Inamur Rahman