Expand All

  Getting Started



  Row Models




  Third Party


Github stars make projects look great. Please help, donate a star, it's free.
Get informed on releases and other ag-Grid news only - never spam.
Follow on Twitter

Text Filter

Text filters allow users to filter data based on the text contained in the column where this filter is defined. To create a new text filter in a column, all you need to do is:

  1. Enable filtering on that column
  2. Set the filter type to text

In order to set the filter type to text you need to add the following to your column definition


Enterprise users have Set Filter as the default type

Non enterprise users have text filter as the default filter type. If you are not enterprise user, you don't need to specify filter:'text' since it is your default filter type

Text Filter Parameters

A text filter can take the following parameters:

  • newRowsAction: What to do when new rows are loaded. The default is to reset the filter. If you want to keep the filter status between row loads, then set this value to 'keep'.
  • applyButton: Set to true to include an 'Apply' button with the filter and not filter automatically as the selection changes.
  • clearButton: Set to true to include a 'Clear' button with the filter which when cliked will remove the filter conditions to this filter.
  • textCustomComparator: Used to override what to filter based on the user input. See textCustomComparator section below
  • filterOptions: If specified, limits the amount of options presented in the filter UI, it must be a string array containing some of the following values {equals, notEqual, contains, notContains, startsWith, endsWith}
The parameters for the filter must be specified in the property filterParams inside the column definition object


Text Custom Comparator

By default the text filter does strict case insensitive text filtering: ie If you provide as data for a text column the following values ['1,234.5USD', '345GBP']:

  • contains '1,2' Will show 1 value: ['1,234.5USD']
  • contains '12' Will show 0 values
  • contains '$' Will show 0 values
  • contains 'gbp' Will show 1 value ['345GBP']

You can change the default behaviour by providing your own textCustomComparator. Using your own textCustomComparator you can provide your own logic to decide when to include a row in the filtered results.

The textCustomComparator is a function with the following signature:

(filter:string, gridValue:any, filterText:string):boolean;
  • filter:string The applicable filter type being tested. One of: {equals, notEqual, contains, notContains, startsWith, endsWith}
  • gridValue:any The value about to be filtered, if this column has a value getter, this value will be coming off the value getter, otherwise it is the raw value injected into the grid
  • filterText:string The value to filter by.
  • returns:boolean True if the value passes the filter, otherwise false.

The following is an example of a textCustomComparator that mimics the current implementation of ag-Grid. This can be used as a template to create your own.

function myComparator (filter, value, filterText){
    var filterTextLoweCase = filterText.toLowerCase();
    var valueLowerCase = value.toString().toLowerCase();
    switch (filter) {
    case 'contains':
        return valueLowerCase.indexOf(filterTextLoweCase) >= 0;
    case 'notContains':
        return valueLowerCase.indexOf(filterTextLoweCase) === -1;
    case 'equals':
        return valueLowerCase === filterTextLoweCase;
    case 'notEqual':
        return valueLowerCase != filterTextLoweCase;
    case 'startsWith':
        return valueLowerCase.indexOf(filterTextLoweCase) === 0;
    case 'endsWith':
        var index = valueLowerCase.lastIndexOf(filterTextLoweCase);
        return index >= 0 && index === (valueLowerCase.length - filterTextLoweCase.length);
        // should never happen
        console.warn('invalid filter type ' + filter);
        return false;

Text Filter Model

Get and set the state of the text filter by getting and setting the model on the filter instance.

// get filter instance
var athleteFilterComponent = gridOptions.api.getFilterInstance('athlete');

// get filter model
var model = athleteFilterComponent.getModel();

// OR set filter model and update

The text filter model has the following attributes:

  • type: The type of text filter to apply. One of: {equals, notEqual, contains, notContains, startsWith, endsWith}
  • filter: The actual filter text to apply.

Floating Text Filter

If your grid has floatingFilter enabled, your columns with text filter will automatically show below the header a new column that will show two elements:

  • Filter input box: This input box serves two purposes:
    1. Lets the user change directly the filtering text that will be used for filtering.
    2. It reflects any change made to the filtering text from anywhere within the application. This includes changes on the rich filter for this column made by the user directly or changes made to the filter through a call to setModel to this filter component
  • Filter button: This button is a shortcut to show the rich filter editor


  • The athlete column has only two filter options: filterOptions=['contains','notContains']
  • The country column has only one filter option: filterOptions=['contains']
  • The country column has a textCustomComparator so that there are aliases that can be entered in the filter ie: if you filter using the text 'usa' it will match United States or 'holland' will match 'Netherlands'

Common Column Filtering Functionality And Examples

The following can be found in the column filtering documentation page

  • Common filtering params
  • Enabling/Disabling filtering in a column
  • Enabling/Disabling floating filter
  • Adding apply and clear button to a column filter
  • Filtering animation
  • Examples