Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Explain that id field is required for multiple filters in DataGridPro #2783

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/src/pages/components/data-grid/filtering/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The filter applied to a column can be pre-configured using the `filterModel` pro
## Predefined filters

A filter is composed of three parts: the column to filter, the value to look for, and an operator (e.g. _contains_, _is before_, _is after_, etc.).
On the `DataGridPro`, the `id` field is required on `filterModel.items` when multiple filters are used.
The operator determines if a candidate value should be considered as a result.
The candidate value used by the operator is the one corresponding to the `field` attribute or the `valueGetter` of the `GridColDef`.
As part of the predefined column types, a set of operators is available.
Expand Down Expand Up @@ -144,13 +145,15 @@ The default operator that will be applied between filters is an And.

{{"demo": "pages/components/data-grid/filtering/MultiFilteringGrid.js", "bg": "inline", "disableAd": true}}

To change the default operator, you should set the 'linkOperator' property of the filterModel like below.
**Note**: The `id` field is required on `filterModel.items` when multiple filters are used.

To change the default operator, you should set the `linkOperator` property of the `filterModel` like below.

```ts
const filterModel: GridFilterModel = {
items: [
{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ columnField: 'commodity', operatorValue: 'startsWith', value: 'Soy' },
{ id: 1, columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ id: 2, columnField: 'commodity', operatorValue: 'startsWith', value: 'Soy' },
],
linkOperator: GridLinkOperator.Or,
};
Expand Down