diff --git a/docs/data/data-grid/filtering/CustomHeaderFilterDataGridPro.js b/docs/data/data-grid/filtering/CustomHeaderFilterDataGridPro.js index 4cd9c80e0acde..245124b306372 100644 --- a/docs/data/data-grid/filtering/CustomHeaderFilterDataGridPro.js +++ b/docs/data/data-grid/filtering/CustomHeaderFilterDataGridPro.js @@ -64,7 +64,7 @@ function CustomHeaderFilter(props) { + + {headerFilterMenu} - - - {clearButton} - + ); } diff --git a/docs/data/data-grid/filtering/CustomHeaderFilterOperatorDataGridPro.tsx b/docs/data/data-grid/filtering/CustomHeaderFilterOperatorDataGridPro.tsx index 0276f0e9e4299..66df4353255b4 100644 --- a/docs/data/data-grid/filtering/CustomHeaderFilterOperatorDataGridPro.tsx +++ b/docs/data/data-grid/filtering/CustomHeaderFilterOperatorDataGridPro.tsx @@ -32,28 +32,25 @@ function RatingInputValue( }; return ( - + + {headerFilterMenu} - - - {clearButton} - + ); } diff --git a/docs/data/data-grid/filtering/CustomHeaderFilterSingleDataGridPro.js b/docs/data/data-grid/filtering/CustomHeaderFilterSingleDataGridPro.js index 0ed5ea252ea16..3a5c2edc10948 100644 --- a/docs/data/data-grid/filtering/CustomHeaderFilterSingleDataGridPro.js +++ b/docs/data/data-grid/filtering/CustomHeaderFilterSingleDataGridPro.js @@ -42,14 +42,18 @@ function AdminFilter(props) { const label = !value ? 'Filter' : 'Is admin'; return ( - - {label} + + + {label} + None diff --git a/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.js b/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.js new file mode 100644 index 0000000000000..e02a8bd8e2a5e --- /dev/null +++ b/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.js @@ -0,0 +1,48 @@ +import * as React from 'react'; +import { DataGridPro } from '@mui/x-data-grid-pro'; +import { useDemoData } from '@mui/x-data-grid-generator'; + +const VISIBLE_FIELDS = ['name', 'rating', 'website']; + +export default function HeaderFilteringInlineClearDataGridPro() { + const { data, loading } = useDemoData({ + dataSet: 'Employee', + rowLength: 100, + visibleFields: VISIBLE_FIELDS, + }); + + const columns = React.useMemo(() => { + return data.columns.map((col) => ({ + ...col, + minWidth: 200, + })); + }, [data.columns]); + + return ( +
+ ', value: 2 }, + ], + }, + }, + }} + headerFilters + slotProps={{ + headerFilterCell: { + showClearIcon: true, + }, + }} + /> +
+ ); +} diff --git a/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.tsx b/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.tsx new file mode 100644 index 0000000000000..e02a8bd8e2a5e --- /dev/null +++ b/docs/data/data-grid/filtering/HeaderFilteringInlineClearDataGridPro.tsx @@ -0,0 +1,48 @@ +import * as React from 'react'; +import { DataGridPro } from '@mui/x-data-grid-pro'; +import { useDemoData } from '@mui/x-data-grid-generator'; + +const VISIBLE_FIELDS = ['name', 'rating', 'website']; + +export default function HeaderFilteringInlineClearDataGridPro() { + const { data, loading } = useDemoData({ + dataSet: 'Employee', + rowLength: 100, + visibleFields: VISIBLE_FIELDS, + }); + + const columns = React.useMemo(() => { + return data.columns.map((col) => ({ + ...col, + minWidth: 200, + })); + }, [data.columns]); + + return ( +
+ ', value: 2 }, + ], + }, + }, + }} + headerFilters + slotProps={{ + headerFilterCell: { + showClearIcon: true, + }, + }} + /> +
+ ); +} diff --git a/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.js b/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.js index 712837a9b07c7..cfb56f93dc3b0 100644 --- a/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.js +++ b/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import { DataGridPro } from '@mui/x-data-grid-pro'; +import { DataGridPro, gridClasses } from '@mui/x-data-grid-pro'; import { useDemoData } from '@mui/x-data-grid-generator'; export default function SimpleHeaderFilteringDataGridPro() { @@ -27,6 +27,7 @@ export default function SimpleHeaderFilteringDataGridPro() { slots={{ headerFilterMenu: null, }} + sx={{ [`.${gridClasses['columnHeader--filter']}`]: { px: 1 } }} /> ); diff --git a/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.tsx b/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.tsx index 712837a9b07c7..cfb56f93dc3b0 100644 --- a/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.tsx +++ b/docs/data/data-grid/filtering/SimpleHeaderFilteringDataGridPro.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { DataGridPro } from '@mui/x-data-grid-pro'; +import { DataGridPro, gridClasses } from '@mui/x-data-grid-pro'; import { useDemoData } from '@mui/x-data-grid-generator'; export default function SimpleHeaderFilteringDataGridPro() { @@ -27,6 +27,7 @@ export default function SimpleHeaderFilteringDataGridPro() { slots={{ headerFilterMenu: null, }} + sx={{ [`.${gridClasses['columnHeader--filter']}`]: { px: 1 } }} /> ); diff --git a/docs/data/data-grid/filtering/header-filters.md b/docs/data/data-grid/filtering/header-filters.md index a6ac67a32030e..264c6f1d9164a 100644 --- a/docs/data/data-grid/filtering/header-filters.md +++ b/docs/data/data-grid/filtering/header-filters.md @@ -24,6 +24,12 @@ You can disable the default filter panel using `disableColumnFilter` prop and on {{"demo": "SimpleHeaderFilteringDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}} +## Inline clear button + +The clear button is within the header filter menu by default. To display the clear button in the header filter cell instead, set `slotProps.headerFilterCell.showClearIcon` to `true`. + +{{"demo": "HeaderFilteringInlineClearDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}} + ## Customize header filters There are multiple ways to customize header filters. diff --git a/docs/data/data-grid/localization/data.json b/docs/data/data-grid/localization/data.json index 4c3d17272b69b..9b6f682d08f5f 100644 --- a/docs/data/data-grid/localization/data.json +++ b/docs/data/data-grid/localization/data.json @@ -3,280 +3,280 @@ "languageTag": "ar-SD", "importName": "arSD", "localeName": "Arabic (Sudan)", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/arSD.ts" }, { "languageTag": "be-BY", "importName": "beBY", "localeName": "Belarusian", - "missingKeysCount": 44, - "totalKeysCount": 132, + "missingKeysCount": 45, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/beBY.ts" }, { "languageTag": "bg-BG", "importName": "bgBG", "localeName": "Bulgarian", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/bgBG.ts" }, { "languageTag": "zh-HK", "importName": "zhHK", "localeName": "Chinese (Hong Kong)", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/zhHK.ts" }, { "languageTag": "zh-CN", "importName": "zhCN", "localeName": "Chinese (Simplified)", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/zhCN.ts" }, { "languageTag": "zh-TW", "importName": "zhTW", "localeName": "Chinese (Taiwan)", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/zhTW.ts" }, { "languageTag": "hr-HR", "importName": "hrHR", "localeName": "Croatian", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/hrHR.ts" }, { "languageTag": "cs-CZ", "importName": "csCZ", "localeName": "Czech", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/csCZ.ts" }, { "languageTag": "da-DK", "importName": "daDK", "localeName": "Danish", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/daDK.ts" }, { "languageTag": "nl-NL", "importName": "nlNL", "localeName": "Dutch", - "missingKeysCount": 9, - "totalKeysCount": 132, + "missingKeysCount": 10, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/nlNL.ts" }, { "languageTag": "fi-FI", "importName": "fiFI", "localeName": "Finnish", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/fiFI.ts" }, { "languageTag": "fr-FR", "importName": "frFR", "localeName": "French", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/frFR.ts" }, { "languageTag": "de-DE", "importName": "deDE", "localeName": "German", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/deDE.ts" }, { "languageTag": "el-GR", "importName": "elGR", "localeName": "Greek", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/elGR.ts" }, { "languageTag": "he-IL", "importName": "heIL", "localeName": "Hebrew", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/heIL.ts" }, { "languageTag": "hu-HU", "importName": "huHU", "localeName": "Hungarian", - "missingKeysCount": 16, - "totalKeysCount": 132, + "missingKeysCount": 17, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/huHU.ts" }, { "languageTag": "is-IS", "importName": "isIS", "localeName": "Icelandic", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/isIS.ts" }, { "languageTag": "it-IT", "importName": "itIT", "localeName": "Italian", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/itIT.ts" }, { "languageTag": "ja-JP", "importName": "jaJP", "localeName": "Japanese", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/jaJP.ts" }, { "languageTag": "ko-KR", "importName": "koKR", "localeName": "Korean", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/koKR.ts" }, { "languageTag": "nb-NO", "importName": "nbNO", "localeName": "Norwegian (Bokmål)", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/nbNO.ts" }, { "languageTag": "nn-NO", "importName": "nnNO", "localeName": "Norwegian (Nynorsk)", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/nnNO.ts" }, { "languageTag": "fa-IR", "importName": "faIR", "localeName": "Persian", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/faIR.ts" }, { "languageTag": "pl-PL", "importName": "plPL", "localeName": "Polish", - "missingKeysCount": 21, - "totalKeysCount": 132, + "missingKeysCount": 22, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/plPL.ts" }, { "languageTag": "pt-PT", "importName": "ptPT", "localeName": "Portuguese", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/ptPT.ts" }, { "languageTag": "pt-BR", "importName": "ptBR", "localeName": "Portuguese (Brazil)", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/ptBR.ts" }, { "languageTag": "ro-RO", "importName": "roRO", "localeName": "Romanian", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/roRO.ts" }, { "languageTag": "ru-RU", "importName": "ruRU", "localeName": "Russian", - "missingKeysCount": 14, - "totalKeysCount": 132, + "missingKeysCount": 15, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/ruRU.ts" }, { "languageTag": "sk-SK", "importName": "skSK", "localeName": "Slovak", - "missingKeysCount": 15, - "totalKeysCount": 132, + "missingKeysCount": 16, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/skSK.ts" }, { "languageTag": "es-ES", "importName": "esES", "localeName": "Spanish", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/esES.ts" }, { "languageTag": "sv-SE", "importName": "svSE", "localeName": "Swedish", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/svSE.ts" }, { "languageTag": "tr-TR", "importName": "trTR", "localeName": "Turkish", - "missingKeysCount": 0, - "totalKeysCount": 132, + "missingKeysCount": 1, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/trTR.ts" }, { "languageTag": "uk-UA", "importName": "ukUA", "localeName": "Ukrainian", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/ukUA.ts" }, { "languageTag": "ur-PK", "importName": "urPK", "localeName": "Urdu (Pakistan)", - "missingKeysCount": 18, - "totalKeysCount": 132, + "missingKeysCount": 19, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/urPK.ts" }, { "languageTag": "vi-VN", "importName": "viVN", "localeName": "Vietnamese", - "missingKeysCount": 10, - "totalKeysCount": 132, + "missingKeysCount": 11, + "totalKeysCount": 133, "githubLink": "https://github.com/mui/mui-x/blob/master/packages/x-data-grid/src/locales/viVN.ts" } ] diff --git a/docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md b/docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md index 85b8dfa37d6c5..2ecfcdefb7386 100644 --- a/docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md +++ b/docs/data/migration/migration-data-grid-v7/migration-data-grid-v7.md @@ -99,6 +99,10 @@ Below are described the steps you need to make to migrate from v7 to v8. - `ariaV8` experimental flag is removed. It's now the default behavior. +### Filtering + +- The clear button in header filter cells has moved to the header filter menu. Use `slotProps={{ headerFilterCell: { showClearIcon: true } }}` to restore the clear button in the cell. +