A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.ag-grid.com/javascript-data-grid/filter-advanced/ below:

JavaScript Grid: Advanced Filter | AG Grid

The Advanced Filter allows for complex filter conditions to be entered across columns in a single type-ahead input, as well as within a hierarchical visual builder.

Enabling Advanced Filter Copy Link

The Advanced Filter is enabled by setting the property enableAdvancedFilter = true. By default, the Advanced Filter is displayed between the column headers and the grid rows, where the Floating Filters would be displayed if they were enabled.

const gridOptions = {
    enableAdvancedFilter: true,

    
}

The following example demonstrates the Advanced Filter:

Advanced Filter and Column Filters cannot be active at the same time. Enabling Advanced Filter will disable Column Filters.

Advanced Filter Builder Copy Link

As well as typing into the Advanced Filter input, Advanced Filters can also be set by using the Advanced Filter Builder. This displays a hierarchical view of the filter, and allows the different filter parts to be set using dropdowns and inputs. It also allows for filter conditions to be added, deleted and reordered.

The Advanced Filter Builder can be launched by clicking the Builder button next to the Advanced Filter input.

The following example demonstrates the Advanced Filter Builder:

Configuring Columns Copy Link

For a column to appear in the Advanced Filter, it needs to have filter: true (or set to a non-null and non-false value).

The type of the filter options displayed is based on the Cell Data Type of the column.

The different properties that can be set for each column are explained in the sections below, and demonstrated in the following example:

Including Hidden Columns Copy Link

By default, hidden columns do not appear in the Advanced Filter. To make hidden columns appear, set includeHiddenColumnsInAdvancedFilter = true.

includeHiddenColumnsInAdvancedFilterCopy Link

boolean

default: false

Hidden columns are excluded from the Advanced Filter by default. To include hidden columns, set to true.

AdvancedFilterModule Row Grouping Copy Link

When Row Grouping, group columns will not appear in the Advanced Filter. The underlying columns will always appear, even if hidden.

Column Names Copy Link

The name by which columns appear in the Advanced Filter can be configured by using a Header Value Getter and checking for location = 'advancedFilter'.

Filter Parameters Copy Link

Certain properties can be set by using colDef.filterParams.

const gridOptions = {
    columnDefs: [
        {
            field: 'athlete',
            filterParams: {
                
                caseSensitive: true,
                
                filterOptions: ['contains'],
            }
        }
    ],

    
}

For all Cell Data Types, the available filter options can be set via filterOptions.

The available options are as follows:

Option Name Option Key Cell Data Type contains contains text, object does not contain notContains text, object equals equals text, object = equals number, date, dateString, dateTime, dateTimeString not equal notEqual text, object != notEqual number, date, dateString, dateTime, dateTimeString begins with startsWith text, object ends with endsWith text, object is blank blank text, number, boolean, date, dateString, dateTime, dateTimeString, object is not blank notBlank text, number, boolean, date, dateString, dateTime, dateTimeString, object > greaterThan number, date, dateString, dateTime, dateTimeString >= greaterThanOrEqual number, date, dateString, dateTime, dateTimeString < lessThan number, date, dateString, dateTime, dateTimeString <= lessThanOrEqual number, date, dateString, dateTime, dateTimeString is true true boolean is false false boolean

For text and object Cell Data Types, caseSensitive = true can be set to enable case sensitivity.

For number, date, dateString, dateTime and dateTimeString Cell Data Types, the following properties can be set to include blank values for the relevant options:

These settings only apply when using the Client-Side Row Model. You need to implement support for these in your server-side filtering logic when using the Server-Side Row Model.

Filter Model / API Copy Link

The Advanced Filter model describes the current state of the Advanced Filter. This is represented by an AdvancedFilterModel, which is either a ColumnAdvancedFilterModel for a single condition, or a JoinAdvancedFilterModel for multiple conditions:

'join'

'join'

'AND' | 'OR'

How the conditions are joined together

AdvancedFilterModel[]

The filter conditions that are joined by the type

For example, the Advanced Filter ([Age] > 23 OR [Sport] ends with "ing") AND [Country] contains "united" would be represented by the following model:

const advancedFilterModel = {
    filterType: 'join',
    type: 'AND',
    conditions: [
      {
        filterType: 'join',
        type: 'OR',
        conditions: [
          {
            filterType: 'number',
            colId: 'age',
            type: 'greaterThan',
            filter: 23,
          },
          {
            filterType: 'text',
            colId: 'sport',
            type: 'endsWith',
            filter: 'ing',
          }
        ]
      },
      {
        filterType: 'text',
        colId: 'country',
        type: 'contains',
        filter: 'united',
      }
    ]
};

The Advanced Filter Model can be retrieved via the API method getAdvancedFilterModel, and set via the API method setAdvancedFilterModel.

Function

Get the state of the Advanced Filter. Used for saving Advanced Filter state

AdvancedFilterModule

Function

Set the state of the Advanced Filter. Used for restoring Advanced Filter state

AdvancedFilterModule

The Advanced Filter Model can be saved and restored as part of Grid State.

The Advanced Filter Model and API methods are demonstrated in the following example:

Configuring Advanced Filter Copy Link

It is possible to customise the buttons displayed in the Advanced Filter, allowing for the use of other Filter Buttons such as Reset, Cancel and Clear.

The Advanced Filter can be configured using the IAdvancedFilterParams interface:

FilterAction[]

default: ['apply']

Specifies the buttons to be shown in the Advanced Filter, in the order they should be displayed in. The options are:

  • 'apply': The Apply button will apply the filter.
  • 'clear': The Clear button will clear the filter input without removing the current active filter.
  • 'reset': The Reset button will clear the filter and apply an empty filter.
  • 'cancel': The Cancel button will discard any changes that have been made to the filter in the UI, restoring the applied model.
  • boolean

    default: false

    Whether to hide the Builder button to open the Advanced Filter Builder

    The params can be set via the grid option advancedFilterParams:

    The following example demonstrates configuring the Advanced Filter:

    Advanced Filter Parent Copy Link

    By default the Advanced Filter is displayed underneath the Column Headers, where the Floating Filters would normally appear.

    It is possible to instead display the Advanced Filter outside of the grid (such as above it). This can be done by setting the grid option advancedFilterParent and providing it with a DOM element to contain the filter.

    HTMLElement | null

    DOM element to use as the parent for the Advanced Filter to allow it to appear outside of the grid. Set to null or undefined to appear inside the grid.

    AdvancedFilterModule

    The Popup Parent must also be set to an element that contains both the Advanced Filter parent and the grid.

    The following example demonstrates displaying the Advanced Filter outside of the grid:

    Configuring Advanced Filter Builder Copy Link

    The Advanced Filter Builder can be configured using the IAdvancedFilterBuilderParams interface:

    number

    default: 120

    Width in pixels of the Advanced Filter Builder add button select popup.

    FilterAction[]

    default: ['apply', 'cancel']

    Specifies the buttons to be shown in the Advanced Filter Builder, in the order they should be displayed in. The options are:

  • 'apply': The Apply button will apply the filter and close the builder.
  • 'clear': The Clear button will clear the filter in the builder without removing the current active filter.
  • 'reset': The Reset button will clear the filter and apply an empty filter.
  • 'cancel': The Cancel button will discard any changes that have been made to the filter in the UI, and close the Builder without applying any changes.
  • number

    default: 500

    Minimum width in pixels of the Advanced Filter Builder popup.

    number

    default: 200

    Max width in pixels of the Advanced Filter Builder pill select popup.

    number

    default: 140

    Min width in pixels of the Advanced Filter Builder pill select popup.

    boolean

    default: false

    Whether to show the move up and move down buttons in the Advanced Filter Builder.

    boolean

    default: false

    Whether to hide the Full Screen button in the Advanced Filter Builder.

    The params can be set via the grid option advancedFilterBuilderParams:

    IAdvancedFilterBuilderParams

    Customise the parameters passed to the Advanced Filter Builder.

    AdvancedFilterModule

    As well as using the button in the Advanced Filter, it's possible to launch the Advanced Filter Builder via the showAdvancedFilterBuilder grid API method, and hide it via hideAdvancedFilterBuilder:

    Function

    Open the Advanced Filter Builder dialog (if enabled).

    AdvancedFilterModule

    Function

    Closes the Advanced Filter Builder dialog (if enabled). Un-applied changes are discarded.

    AdvancedFilterModule

    When the Advanced Filter Builder is shown or hidden, the advancedFilterBuilderVisibleChanged event is fired:

    AdvancedFilterBuilderVisibleChangedEvent

    Advanced Filter Builder visibility has changed (opened or closed).

    The following example demonstrates configuring the Advanced Filter Builder:

    Cell Data Type Handling Copy Link

    All of the Cell Data Types are supported in the Advanced Filter. The behaviour of each is described below.

    Aggregation / Pivoting Copy Link

    The Advanced Filter will only work on leaf-level rows when using Aggregation. The groupAggFiltering property will be ignored.

    When Pivoting, Pivot Result Columns will not appear in the Advanced Filter. However, primary columns (including underlying group and pivot columns) will be shown in the Advanced Filter.

    Server-Side Row Model Copy Link

    In addition to the Client-Side Row Model, the Advanced Filter can be used with the Server-Side Row Model. See the SSRM Advanced Filter Example for more information.

    Localisation Copy Link

    If providing custom Localisation values for the Advanced Filter, note that if the filter option values contain spaces, one option value cannot start with another option value.

    Next Up Copy Link

    Continue to the next section to learn about External Filters.


    RetroSearch is an open source project built by @garambo | Open a GitHub Issue

    Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

    HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4