You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data/data-grid/filtering/header-filters.md
+49-28Lines changed: 49 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,33 +4,37 @@ title: Data Grid - Header filters
4
4
5
5
# Data Grid - Header filters [<spanclass="plan-pro"></span>](/x/introduction/licensing/#pro-plan'Pro plan')
6
6
7
-
<pclass="description">Quickly accessible per-column filters on grid header.</p>
7
+
<pclass="description">Give users quick-access column filters in the Data Grid header.</p>
8
8
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.
10
12
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><kbdclass="key">⌘ Command</kbd>+<kbdclass="key">Enter</kbd></kbd> (or <kbd><kbdclass="key">Ctrl</kbd>+<kbdclass="key">Enter</kbd></kbd> on Windows) when focusing on a header filter cell.
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
16
18
17
-
You can switch between different operators by clicking the operator button in the header filter cell or pressing <kbd><kbdclass="key">Ctrl</kbd>+<kbdclass="key">Enter</kbd></kbd> (or <kbd><kbdclass="key">⌘ Command</kbd>+<kbdclass="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:
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`.
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:
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:
53
57
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.
The default slot component handles keyboard navigation and focus management, so your custom component should also account for these accessibility features.
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
+
:::
61
70
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
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.
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:
74
84
75
85
```tsx
76
86
<DataGridPro{...data}headerFilterHeight={52} />
77
87
```
78
88
79
89
## Ignore diacritics (accents)
80
90
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
+
<DataGridignoreDiacritics />
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/).
Copy file name to clipboardExpand all lines: docs/data/data-grid/filtering/index.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,7 +157,18 @@ To send the user back to the first page when a new filter is applied, use the `r
157
157
158
158
## Ignore diacritics (accents)
159
159
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
+
<DataGridignoreDiacritics />
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/).
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.
19
22
20
-
### Use cases
23
+
### One filter per column
21
24
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:
To disable multi-filtering, pass the `disableMultipleColumnsFiltering` to the Data Grid Pro.
32
+
33
+
```tsx
34
+
<DataGridProdisableMultipleColumnsFiltering />
35
+
```
36
+
37
+
### Remove multi-filter action buttons
30
38
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:
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/).
0 commit comments