Skip to content

Commit e8363cc

Browse files
github-actions[bot]mapache-salvajecherniavskii
authored
[data grid][docs] Revise the Pro filter docs (@mapache-salvaje) (#18815)
Signed-off-by: mapache-salvaje <[email protected]> Co-authored-by: mapache-salvaje <[email protected]> Co-authored-by: Andrew Cherniavskii <[email protected]> Co-authored-by: Sycamore <[email protected]>
1 parent c050a74 commit e8363cc

File tree

4 files changed

+91
-49
lines changed

4 files changed

+91
-49
lines changed

docs/data/data-grid/filtering/header-filters.md

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,37 @@ title: Data Grid - Header filters
44

55
# Data Grid - Header filters [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')
66

7-
<p class="description">Quickly accessible per-column filters on grid header.</p>
7+
<p class="description">Give users quick-access column filters in the Data Grid header.</p>
88

9-
:::warning
9+
By default, users access the Data Grid's filtering features through the filter panel in the toolbar.
10+
The header filter feature adds a row to the top of the Data Grid Pro that lets users quickly filter columns directly in place.
11+
Filters added through the filter panel are synchronized with header filters, and vice versa.
1012

11-
To use header filters, you need to upgrade to the [Pro plan](/x/introduction/licensing/#pro-plan) or above.
13+
In the demo below, you can switch between different operators by clicking the operator button in the header filter cell or pressing <kbd><kbd class="key">⌘ Command</kbd>+<kbd class="key">Enter</kbd></kbd> (or <kbd><kbd class="key">Ctrl</kbd>+<kbd class="key">Enter</kbd></kbd> on Windows) when focusing on a header filter cell.
1214

13-
:::
15+
{{"demo": "HeaderFilteringDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
1416

15-
Header filters add a new header row that lets users quickly filter the columns. The filters added on the filter panel are synchronized with the header filters and vice versa.
17+
## Implementing header filters
1618

17-
You can switch between different operators by clicking the operator button in the header filter cell or pressing <kbd><kbd class="key">Ctrl</kbd>+<kbd class="key">Enter</kbd></kbd> (or <kbd><kbd class="key">⌘ Command</kbd>+<kbd class="key">Enter</kbd></kbd> on macOS) when focusing on a header filter cell.
19+
To enable header filters, pass the `headerFilters` prop to the Data Grid Pro:
1820

19-
{{"demo": "HeaderFilteringDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
21+
```tsx
22+
<DataGridPro headerFilters>
23+
```
2024

21-
## Simple header filters
25+
### Disabling the default filter panel
2226

23-
You can disable the default filter panel using `disableColumnFilter` prop and only show the default operator by passing `slots.headerFilterMenu` as `null`.
27+
You can disable the default filter panel using the `disableColumnFilter` prop, and show only the default operator by passing `slots.headerFilterMenu` as `null`.
2428

2529
{{"demo": "SimpleHeaderFilteringDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
2630

27-
## Customize header filters
31+
## Customizing header filters
2832

29-
There are multiple ways to customize header filters.
33+
You can override header filter cells individually or across the entire row.
3034

31-
### `renderHeaderFilter` method
35+
### One header filter cell in a specific column
3236

33-
You can use the `renderHeaderFilter` method of the `GridColDef` to customize the header filter cell for a specific column.
37+
Use the `renderHeaderFilter()` method of the `GridColDef` to customize the header filter cell for a specific column.
3438

3539
```tsx
3640
const columns: GridColDef[] = [
@@ -43,42 +47,59 @@ const columns: GridColDef[] = [
4347
];
4448
```
4549

46-
The following demo uses the `renderHeaderFilter` method to customize the header filter cell for the `isAdmin` column and hide the filter cell for the `phone` column.
50+
The demo below uses the `renderHeaderFilter()` method to hide the header filter cell for the **Phone** column and customize it for the **Is admin?** column:
4751

4852
{{"demo": "CustomHeaderFilterSingleDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
4953

50-
### Customize using `filterOperators`
54+
### All header filter cells in every column
5155

52-
If the filter operator has a [custom `InputComponent`](https://mui.com/x/react-data-grid/filtering/#custom-input-component), the same component is being used for the header filter.
56+
Use `slots.headerFilterCell` to override all header filter cells in the row with a custom component:
5357

54-
When rendered as a header filter, the `InputComponent` also receives the `headerFilterMenu` and `clearButton` props that contain the filter operator menu and clear button.
58+
```tsx
59+
<DataGridPro {...data} slots={{ headerFilterCell: MyCustomHeaderFilterCell }} />
60+
```
5561

56-
{{"demo": "CustomHeaderFilterOperatorDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
62+
The default slot component handles keyboard navigation and focus management, so your custom component should also account for these accessibility features.
63+
The demo below shows how to do this.
5764

58-
### `headerFilterCell` slot
65+
{{"demo": "CustomHeaderFilterDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
5966

60-
You can use `slots.headerFilterCell` to customize the header filter cell completely. Since the default slot component handles keyboard navigation and focus management, you may have to handle them yourself if you are using a custom component.
67+
:::success
68+
Similarly, you can use `slots.headerFilterMenu` if you need to customize the header filter menu.
69+
:::
6170

62-
Additionally, `slots.headerFilterMenu` could also be used to customize the menu of the header filter cell.
71+
### Header filter cells with custom filter operators
6372

64-
```tsx
65-
<DataGridPro {...data} slots={{ headerFilterCell: MyCustomHeaderFilterCell }} />
66-
```
73+
If you're using a [custom input component](/x/react-data-grid/filtering/customization/#custom-input-component) for the filter operator, you can use that same component in the header filter cell for a better user experience.
74+
The custom input component receives the `headerFilterMenu` and `clearButton` props that you can use to render the filter operator menu and **Clear filter** button, respectively.
6775

68-
{{"demo": "CustomHeaderFilterDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
76+
In the demo below, the **Rating** column uses a custom input, and you can filter by clicking on a star rating in the header filter cell:
6977

70-
### Custom header filter height
78+
{{"demo": "CustomHeaderFilterOperatorDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
79+
80+
### Header filter row height
7181

7282
By default, the height of the header filter row is the same as the header row (represented by `columnHeaderHeight` prop).
73-
You can customize the height of the header filter cell using the `headerFilterHeight` prop.
83+
You can use the the `headerFilterHeight` prop to change this:
7484

7585
```tsx
7686
<DataGridPro {...data} headerFilterHeight={52} />
7787
```
7888

7989
## Ignore diacritics (accents)
8090

81-
You can ignore diacritics (accents) when filtering the rows. See [Quick filter - Ignore diacritics (accents)](/x/react-data-grid/filtering/quick-filter/#ignore-diacritics-accents).
91+
When filtering, diacritics—accented letters such as _é_ or _à_—are considered distinct from their standard counterparts (_e_ and _a_).
92+
This can lead to a poor experience when users expect them to be treated as equivalent.
93+
94+
If your dataset includes diacritics that need to be ignored, you can pass the `ignoreDiacritics` prop to the Data Grid:
95+
96+
```tsx
97+
<DataGrid ignoreDiacritics />
98+
```
99+
100+
:::info
101+
The `ignoreDiacritics` prop affects all columns and filter types, including [standard filters](/x/react-data-grid/filtering/), [quick filters](/x/react-data-grid/filtering/quick-filter/), and [header filters](/x/react-data-grid/filtering/header-filters/).
102+
:::
82103

83104
## API
84105

docs/data/data-grid/filtering/index.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ To send the user back to the first page when a new filter is applied, use the `r
157157

158158
## Ignore diacritics (accents)
159159

160-
You can ignore diacritics (accents) when filtering the rows. See [Quick filter - Ignore diacritics (accents)](/x/react-data-grid/filtering/quick-filter/#ignore-diacritics-accents).
160+
When filtering, diacritics—accented letters such as _é_ or _à_—are considered distinct from their standard counterparts (_e_ and _a_).
161+
This can lead to a poor experience when users expect them to be treated as equivalent.
162+
163+
If your dataset includes diacritics that need to be ignored, you can pass the `ignoreDiacritics` prop to the Data Grid:
164+
165+
```tsx
166+
<DataGrid ignoreDiacritics />
167+
```
168+
169+
:::info
170+
The `ignoreDiacritics` prop affects all columns and filter types, including [standard filters](/x/react-data-grid/filtering/), [quick filters](/x/react-data-grid/filtering/quick-filter/), and [header filters](/x/react-data-grid/filtering/header-filters/).
171+
:::
161172

162173
## apiRef
163174

docs/data/data-grid/filtering/multi-filters.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
---
2-
title: Data Grid - Multi filters
2+
title: Data Grid - Multi-filters
33
---
44

5-
# Data Grid - Multi filters [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')
5+
# Data Grid - Multi-filters [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan 'Pro plan')
66

7-
<p class="description">Apply multiple filters at the same time.</p>
7+
<p class="description">Let end users apply multiple filters to the Data Grid simultaneously.</p>
88

9-
Multi filters allow filtering rows by multiple columns with multiple criteria.
10-
To add more filters, use the `Add Filter` button on the filter panel.
9+
By default, it's only possible to apply one filter at a time to the Data Grid.
10+
With the Data Grid Pro, users can apply multiple filters based on different criteria for more fine-grained data analysis.
11+
They can apply multiple filters to a single column and multiple columns simultaneously.
1112

12-
The following demo lets you filter the rows according to several criteria at the same time.
13+
The demo below shows how this feature works.
14+
Click the filter icon to open the menu and add the first filter—the Data Grid dynamically responds as you enter a value.
15+
Then click **Add Filter** to apply additional criteria.
1316

1417
{{"demo": "BasicExampleDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
1518

16-
## One filter per column
19+
## Implementing multi-filters
1720

18-
You can also limit to only one filter per column while still allowing to filter other columns. For this, use the [`filterColumns`](/x/api/data-grid/grid-filter-form/) and [`getColumnForNewFilter`](/x/api/data-grid/grid-filter-panel/) props available in `slotProps.filterPanel`.
21+
The multi-filter feature is available by default with the Data Grid Pro and doesn't require any additional configuration.
1922

20-
### Use cases
23+
### One filter per column
2124

22-
- Sometimes it's a limitation of some server-side filtering APIs to only allow one filter per column.
23-
- You can also write custom logic to prevent some columns from being shown as possible filters.
24-
25-
This demo implements a basic use case to prevent showing multiple filters for one column.
25+
To limit the user to only applying one filter to any given column, you can use the [`filterColumns`](/x/api/data-grid/grid-filter-form/) and [`getColumnForNewFilter`](/x/api/data-grid/grid-filter-panel/) props available to `slotProps.filterPanel` as shown in the demo below:
2626

2727
{{"demo": "DisableMultiFiltersDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
2828

29-
## Disable action buttons
29+
## Disabling multi-filters
30+
31+
To disable multi-filtering, pass the `disableMultipleColumnsFiltering` to the Data Grid Pro.
32+
33+
```tsx
34+
<DataGridPro disableMultipleColumnsFiltering />
35+
```
36+
37+
### Remove multi-filter action buttons
3038

31-
To disable `Add filter` or `Remove all` buttons, pass `disableAddFilterButton` or `disableRemoveAllButton` to `componentsProps.filterPanel`.
39+
To disable the **Add Filter** or **Remove All** buttons, pass `disableAddFilterButton` or `disableRemoveAllButton`, respectively, to `componentsProps.filterPanel` as shown below:
3240

3341
{{"demo": "DisableActionButtonsDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}
3442

docs/data/data-grid/filtering/quick-filter.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,21 @@ In the following demo, the quick filter value `"Saint Martin, Saint Lucia"` will
128128

129129
## Ignore diacritics (accents)
130130

131-
In some languages, the letters can have diacritics (accents) - for instance, the letter `é` in French.
132-
By default, these letters are considered different from their non-accented versions when filtering.
131+
When filtering, diacritics—accented letters such as _é_ or _à_—are considered distinct from their standard counterparts (_e_ and _a_).
132+
This can lead to a poor experience when users expect them to be treated as equivalent.
133133

134-
To ignore diacritics, set the `ignoreDiacritics` prop to `true`:
134+
If your dataset includes diacritics that need to be ignored, you can pass the `ignoreDiacritics` prop to the Data Grid:
135135

136136
```tsx
137137
<DataGrid ignoreDiacritics />
138138
```
139139

140+
In the demo below, you can use the **Ignore diacritics** toggle to see how the filtering behavior changes:
141+
140142
{{"demo": "QuickFilteringDiacritics.js", "bg": "inline", "defaultCodeOpen": false}}
141143

142-
:::warning
143-
Note that the `ignoreDiacritics` prop affects all columns and all filter types: [normal filters](/x/react-data-grid/filtering/), [quick filter](/x/react-data-grid/filtering/quick-filter/) and [header filters](/x/react-data-grid/filtering/header-filters/).
144+
:::info
145+
The `ignoreDiacritics` prop affects all columns and filter types, including [standard filters](/x/react-data-grid/filtering/), [quick filters](/x/react-data-grid/filtering/quick-filter/), and [header filters](/x/react-data-grid/filtering/header-filters/).
144146
:::
145147

146148
## API

0 commit comments

Comments
 (0)