The Advanced Filter allows for complex filter conditions to be entered across columns in a single type-ahead input.
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,
// other grid options ...
}
The following example demonstrates the Advanced Filter:
athlete
into the Advanced Filter input. As you type, the list of suggested column names will be filtered down.Athlete
entry by pressing Enter or Tab, or using the mouse to click on the entry.contains
entry in a similar way.michael
followed by an end quote ("
).Apply
button to execute the filter.michael
.AND
and OR
along with brackets - (
and )
.Advanced Filter and Column Filters cannot be active at the same time. Enabling Advanced Filter will disable Column Filters.
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:
filter = false
.contains
option and is case sensitive.headerValueGetter
defined and use the location
property to have a different name in the filter (with a (-)
suffix).By default, hidden columns do not appear in the Advanced Filter. To make hidden columns appear, set includeHiddenColumnsInAdvancedFilter = true
.
This can also be set via the API method setIncludeHiddenColumnsInAdvancedFilter
.
When Row Grouping, group columns will not appear in the Advanced Filter. The underlying columns will always appear, even if hidden.
The name by which columns appear in the Advanced Filter can be configured by using a Header Value Getter and checking for location = 'advancedFilter'
.
Certain properties can be set by using colDef.filterParams
.
const gridOptions = {
columnDefs: [
{
field: 'athlete',
filterParams: {
// perform case sensitive search
caseSensitive: true,
// limit options to `contains` only
filterOptions: ['contains'],
}
}
],
// other grid options ...
}
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 |
not equal | notEqual | text , object |
!= | notEqual | number , date , dateString |
starts with | startsWith | text , object |
ends with | endsWith | text , object |
is blank | blank | text , number , boolean , date , dateString , object |
is not blank | notBlank | text , number , boolean , date , dateString , object |
> | greaterThan | number , date , dateString |
>= | greaterThanOrEqual | number , date , dateString |
< | lessThan | number , date , dateString |
<= | lessThanOrEqual | number , date , dateString |
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
and dateString
Cell Data Types, the following properties can be set to include blank values for the relevant options:
includeBlanksInEquals = true
includeBlanksInLessThan = true
includeBlanksInGreaterThan = true
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:
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 grid option advancedFilterModel
or via the API method setAdvancedFilterModel
.
The Advanced Filter Model and API methods are demonstrated in the following example:
advancedFilterModel
is set so the Advanced Filter is automatically populated, and the grid is filtered.Save Advanced Filter Model
will save the current Advanced Filter.Restore Advanced Filter Model
will restore the previously saved Advanced Filter.Set Custom Advanced Filter Model
will set [Gold] >= 1
.Clear Advanced Filter
will clear the current Advanced Filter.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. It is also possible to call the API method setAdvancedFilterParent
.
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:
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.