Framework:Javascript Data GridAngular Data GridReact Data GridVue Data Grid

React Data Grid: Set Filter - Overview

The Set Filter takes inspiration from Excel's AutoFilter and allows filtering on sets of data. It is built on top of the shared functionality that is common across all Provided Filters.

Set Filter

Set Filter Sections

The Set Filter is comprised of the following sections:

  • Mini Filter: used to narrow the values available for selection inside the Filter List.
  • Select All: used to select / deselect all values shown in the Filter List.
  • Filter List: a list of Set Filter Values which can be selected / deselected to set the filter.
  • Filter Buttons: Action buttons that can be optionally added to the bottom of the Set Filter.

Enabling Set Filters

The Set Filter is the default filter used in AG Grid Enterprise, but it can also be explicitly configured as shown below:

const columnDefs = [
    // Set Filter is used by default in Enterprise version
    { field: 'athlete', filter: true },
    // explicitly configure column to use the Set Filter
    { field: 'country', filter: 'agSetColumnFilter' },
];

<AgGridReact columnDefs={columnDefs}></AgGridReact>

The following example demonstrates how the Set Filter can be enabled. Note the following:

  • The Athlete column has filter=true which defaults to the Set Filter as this example is using AG Grid Enterprise.
  • The Country column is explicitly configured to use the Set Filter using filter='agSetColumnFilter'.
  • All other columns are configured to use the Number Filter using filter='agNumberColumnFilter'.
  • Filters can be accessed from the Column Menu or by clicking on the filter icon in the Floating Filters.

Set Filter Parameters

Parameters that are common to all Provided Filters:

buttons
FilterButtonType[]
Specifies the buttons to be shown in the filter, in the order they should be displayed in. The options are:
  • 'apply': If the Apply button is present, the filter is only applied after the user hits the Apply button.
  • 'clear': The Clear button will clear the (form) details of the filter without removing any active filters on the column.
  • 'reset': The Reset button will clear the details of the filter and any active filters on that column.
  • 'cancel': The Cancel button will discard any changes that have been made to the filter in the UI, restoring the applied model.
  • buttons: FilterButtonType[];
    
    type FilterButtonType = 
          'apply' 
        | 'clear' 
        | 'reset' 
        | 'cancel'
    
    closeOnApply
    boolean
    If the Apply button is present, the filter popup will be closed immediately when the Apply or Reset button is clicked if this is set to true.
    Default: false
    debounceMs
    number
    Overrides the default debounce time in milliseconds for the filter. Defaults are:
  • TextFilter and NumberFilter: 500ms. (These filters have text field inputs, so a short delay before the input is formatted and the filtering applied is usually appropriate).
  • DateFilter and SetFilter: 0ms
  • readOnly
    boolean
    If set to true, disables controls in the filter to mutate its state. Normally this would be used in conjunction with the Filter API. See Read-only Filter UI.
    Default: false
    valueGetter
    ValueGetterFunc
    A function callback for the filter to get cell values from provided row data. Called with a ValueGetterParams to get the value for this filter's column for the provided row data. The callback takes care of selecting the right column definition and deciding whether to use the column valueGetter or raw field etc.
    valueGetter: ValueGetterFunc<TData>;
    
    interface ValueGetterFunc<TData = any> {
        (params: ValueGetterParams<TData>) : any
    }
    
    interface ValueGetterParams<TData = any> {
      // A utility method for getting other column values 
      getValue: (field: string) => any;
      // Row node for the given row 
      node: RowNode<TData> | null;
      // Data associated with the node 
      data: TData | undefined;
      // Column for this callback 
      column: Column;
      // ColDef provided for this column 
      colDef: ColDef<TData>;
      // The grid api. 
      api: GridApi<TData>;
      // The column api. 
      columnApi: ColumnApi;
      // Application context as set on `gridOptions.context`. 
      context: any;
    }

    Parameters that are specific to the Set Filter:

    values
    SetFilterValues
    The values to display in the Filter List. If this is not set, the filter will takes its values from what is loaded in the table. See Supplying Filter Values.
    values: SetFilterValues;
    
    type SetFilterValues = 
          SetFilterValuesFunc<TData> 
        | any[]
    
    
    type SetFilterValuesFunc = 
          (params: SetFilterValuesFuncParams<TData>) => void
    
    
    interface SetFilterValuesFuncParams<TData = any> {
      // The function to call with the values to load into the filter once they are ready. 
      success: (values: string[]) => void;
      // The column definition from which the set filter is invoked. 
      colDef: ColDef<TData>;
      // Column from which the set filter is invoked. 
      column: Column;
      columnApi: ColumnApi;
      api: GridApi<TData>;
      // The context as provided on `gridOptions.context` 
      context: any;
    }
    refreshValuesOnOpen
    boolean
    Refresh the values every time the Set filter is opened. See Refreshing Values.
    cellHeight
    number
    The height of values in the Filter List in pixels.
    suppressSorting
    boolean
    If true, the Set Filter values will not be sorted. Use this if you are providing your own values and don't want them sorted as you are providing in the order you want. See Supplying Filter Values.
    Default: false
    suppressMiniFilter
    boolean
    Set to true to hide the Mini Filter. See Hiding the Mini Filter.
    Default: false
    applyMiniFilterWhileTyping
    boolean
    Set to true to apply the Set Filter immediately when the user is typing in the Mini Filter. See Keyboard Shortcuts.
    Default: false
    suppressSelectAll
    boolean
    Set to true to remove the Select All checkbox.
    Default: false
    defaultToNothingSelected
    boolean
    By default, when the Set Filter is opened all values are shown selected. Set this to true to instead show all values as de-selected by default. See Default State.
    comparator
    Function
    Comparator for sorting. If not provided, the Column Definition comparator is used. If Column Definition comparator is also not provided, the default (grid provided) comparator is used. See Sorting Filter Lists.
    comparator = (
        a: any,
        b: any
    ) => number;
    textFormatter
    Function
    If specified, this formats the text before applying the Mini Filter compare logic, useful for instance to substitute accented characters. See Custom Searches.
    textFormatter = (from: string) => string;
    valueFormatter
    Function
    (params: ValueFormatterParams) => string
    valueFormatter = (
        params: ValueFormatterParams
    ) => string;
    
    interface ValueFormatterParams<TData = any, TValue = any> {
      // Value for the cell. 
      value: TValue;
      // Row node for the given row 
      node: RowNode<TData> | null;
      // Data associated with the node 
      data: TData | undefined;
      // Column for this callback 
      column: Column;
      // ColDef provided for this column 
      colDef: ColDef<TData>;
      // The grid api. 
      api: GridApi<TData>;
      // The column api. 
      columnApi: ColumnApi;
      // Application context as set on `gridOptions.context`. 
      context: any;
    }
    showTooltips
    boolean
    If true, hovering over a value in the Set Filter will show a tooltip containing the full, untruncated value. See Filter Value Tooltips.
    Default: false
    caseSensitive
    boolean
    If true, enables case-sensitivity in the SetFilter Mini-Filter and Filter List.
    Default: false.
    excelMode
    'mac' | 'windows'
    Changes the behaviour of the Set Filter to match that of Excel's AutoFilter. See Excel Mode.

    Next Up

    Continue to the next section: Filter List.