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

[DataGrid] Implement multipleSelect column type #8099

Open
wants to merge 22 commits into
base: v6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion docs/data/data-grid/column-definition/ColumnTypesGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const initialRows = [
},
];

type Row = (typeof initialRows)[number];
type Row = typeof initialRows[number];

export default function ColumnTypesGrid() {
const [rows, setRows] = React.useState<Row[]>(initialRows);
Expand Down
3 changes: 2 additions & 1 deletion docs/data/data-grid/column-definition/column-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ The following are the native column types:
- `'dateTime'`
- `'boolean'`
- `'singleSelect'`
- `'multipleSelect'`
- `'actions'`

### Converting types
Expand All @@ -216,7 +217,7 @@ If for any reason, your data type is not the correct one, you can use `valueGett
To use most of the column types, you only need to define the `type` property in your column definition.
However, some types require additional properties to be set to make them work correctly:

- If the column type is `'singleSelect'`, you also need to set the `valueOptions` property in the respective column definition. These values are options used for filtering and editing.
- If the column type is `'singleSelect'` or `'multipleSelect'`, you also need to set the `valueOptions` property in the respective column definition. These values are options used for filtering and editing.

```tsx
{
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/export/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ The demo below shows how to add a JSON export.
This feature relies on [exceljs](https://github.com/exceljs/exceljs).
The Excel export allows translating columns' type and tree structure of a DataGrid to an Excel file.

Columns with types `'boolean'`, `'number'`, `'singleSelect'`, `'date'`, and `'dateTime'` are exported in their corresponding type in Excel. Please ensure the `rows` values have the correct type, you can always [convert them](/x/react-data-grid/column-definition/#converting-types) as needed.
Columns with types `'boolean'`, `'number'`, `'singleSelect'`, `'multipleSelect'`, `'date'`, and `'dateTime'` are exported in their corresponding type in Excel. Please ensure the `rows` values have the correct type, you can always [convert them](/x/react-data-grid/column-definition/#converting-types) as needed.

{{"demo": "ExcelExport.js", "bg": "inline", "defaultCodeOpen": false}}

Expand Down
23 changes: 12 additions & 11 deletions docs/data/data-grid/filtering/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@ The candidate value used by the operator is the one corresponding to the `field`
Each column type comes with a default array of operators.
You can get them by importing the following functions:

| Column type | Function |
| :------------- | :------------------------------- |
| `string` | `getGridStringOperators()` |
| `number` | `getGridNumericOperators()` |
| `boolean` | `getGridBooleanOperators()` |
| `date` | `getGridDateOperators()` |
| `dateTime` | `getGridDateOperators(true)` |
| `singleSelect` | `getGridSingleSelectOperators()` |
| Column type | Function |
| :--------------- | :--------------------------------- |
| `string` | `getGridStringOperators()` |
| `number` | `getGridNumericOperators()` |
| `boolean` | `getGridBooleanOperators()` |
| `date` | `getGridDateOperators()` |
| `dateTime` | `getGridDateOperators(true)` |
| `singleSelect` | `getGridSingleSelectOperators()` |
| `multipleSelect` | `getGridMultipleSelectOperators()` |

You can find more information about the supported column types in the [columns section](/x/react-data-grid/column-definition/#column-types).

Expand Down Expand Up @@ -368,7 +369,7 @@ The quick filter values can be initialized by setting the `filter.filterModel.qu
### Custom filtering logic

The logic used for quick filter can be switched to filter rows that contain _at least_ one of the values specified instead of testing if it contains all of them.
To do so, set `quickFilterLogicOperator` to `GridLogicOperator.Or` as follow:
To do so, set `quickFilterLogicOperator` to `GridLogicOperator.Or` as follows:

```js
initialState={{
Expand All @@ -381,9 +382,9 @@ initialState={{
}}
```

With the default settings, quick filter will only consider columns with types `'string'`,`'number'`, and `'singleSelect'`.
With the default settings, quick filter will only consider columns with types `'string'`,`'number'`, `'singleSelect'`, and `'multipleSelect'`.

- For `'string'` and `'singleSelect'` columns, the cell's formatted value must **contain** the value
- For `'string'`, `'multipleSelect'`, and `'singleSelect'` columns, the cell's formatted value must **contain** the value
- For `'number'` columns, the cell's formatted value must **equal** the value

To modify or add the quick filter operators, add the property `getApplyQuickFilterFn` to the column definition.
Expand Down
120 changes: 60 additions & 60 deletions docs/data/data-grid/localization/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,240 +3,240 @@
"languageTag": "ar-SD",
"importName": "arSD",
"localeName": "Arabic (Sudan)",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/arSD.ts/"
},
{
"languageTag": "be-BY",
"importName": "beBY",
"localeName": "Belarusian",
"missingKeysCount": 1,
"totalKeysCount": 94,
"missingKeysCount": 3,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/beBY.ts/"
},
{
"languageTag": "bg-BG",
"importName": "bgBG",
"localeName": "Bulgarian",
"missingKeysCount": 7,
"totalKeysCount": 94,
"missingKeysCount": 17,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/bgBG.ts/"
},
{
"languageTag": "zh-CN",
"importName": "zhCN",
"localeName": "Chinese (Simplified)",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/zhCN.ts/"
},
{
"languageTag": "zh-TW",
"importName": "zhTW",
"localeName": "Chinese (Taiwan)",
"missingKeysCount": 8,
"totalKeysCount": 94,
"missingKeysCount": 10,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/zhTW.ts/"
},
{
"languageTag": "cs-CZ",
"importName": "csCZ",
"localeName": "Czech",
"missingKeysCount": 0,
"totalKeysCount": 94,
"missingKeysCount": 2,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/csCZ.ts/"
},
{
"languageTag": "da-DK",
"importName": "daDK",
"localeName": "Danish",
"missingKeysCount": 0,
"totalKeysCount": 94,
"missingKeysCount": 17,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/daDK.ts/"
},
{
"languageTag": "nl-NL",
"importName": "nlNL",
"localeName": "Dutch",
"missingKeysCount": 3,
"totalKeysCount": 94,
"missingKeysCount": 11,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/nlNL.ts/"
},
{
"languageTag": "fi-FI",
"importName": "fiFI",
"localeName": "Finnish",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/fiFI.ts/"
},
{
"languageTag": "fr-FR",
"importName": "frFR",
"localeName": "French",
"missingKeysCount": 8,
"totalKeysCount": 94,
"missingKeysCount": 10,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/frFR.ts/"
},
{
"languageTag": "de-DE",
"importName": "deDE",
"localeName": "German",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/deDE.ts/"
},
{
"languageTag": "el-GR",
"importName": "elGR",
"localeName": "Greek",
"missingKeysCount": 38,
"totalKeysCount": 94,
"missingKeysCount": 40,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/elGR.ts/"
},
{
"languageTag": "he-IL",
"importName": "heIL",
"localeName": "Hebrew",
"missingKeysCount": 10,
"totalKeysCount": 94,
"missingKeysCount": 12,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/heIL.ts/"
},
{
"languageTag": "hu-HU",
"importName": "huHU",
"localeName": "Hungarian",
"missingKeysCount": 14,
"totalKeysCount": 94,
"missingKeysCount": 16,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/huHU.ts/"
},
{
"languageTag": "it-IT",
"importName": "itIT",
"localeName": "Italian",
"missingKeysCount": 8,
"totalKeysCount": 94,
"missingKeysCount": 10,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/itIT.ts/"
},
{
"languageTag": "ja-JP",
"importName": "jaJP",
"localeName": "Japanese",
"missingKeysCount": 1,
"totalKeysCount": 94,
"missingKeysCount": 3,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/jaJP.ts/"
},
{
"languageTag": "ko-KR",
"importName": "koKR",
"localeName": "Korean",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/koKR.ts/"
},
{
"languageTag": "nb-NO",
"importName": "nbNO",
"localeName": "Norwegian (bokmål)",
"missingKeysCount": 8,
"totalKeysCount": 94,
"missingKeysCount": 11,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/nbNO.ts/"
},
{
"languageTag": "fa-IR",
"importName": "faIR",
"localeName": "Persian",
"missingKeysCount": 0,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/faIR.ts/"
},
{
"languageTag": "pl-PL",
"importName": "plPL",
"localeName": "Polish",
"missingKeysCount": 9,
"totalKeysCount": 94,
"missingKeysCount": 11,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/plPL.ts/"
},
{
"languageTag": "pt-BR",
"importName": "ptBR",
"localeName": "Portuguese (Brazil)",
"missingKeysCount": 7,
"totalKeysCount": 94,
"missingKeysCount": 10,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/ptBR.ts/"
},
{
"languageTag": "ro-RO",
"importName": "roRO",
"localeName": "Romanian",
"missingKeysCount": 8,
"totalKeysCount": 94,
"missingKeysCount": 10,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/roRO.ts/"
},
{
"languageTag": "ru-RU",
"importName": "ruRU",
"localeName": "Russian",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/ruRU.ts/"
},
{
"languageTag": "sk-SK",
"importName": "skSK",
"localeName": "Slovak",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/skSK.ts/"
},
{
"languageTag": "es-ES",
"importName": "esES",
"localeName": "Spanish",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/esES.ts/"
},
{
"languageTag": "sv-SE",
"importName": "svSE",
"localeName": "Swedish",
"missingKeysCount": 0,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/svSE.ts/"
},
{
"languageTag": "tr-TR",
"importName": "trTR",
"localeName": "Turkish",
"missingKeysCount": 2,
"totalKeysCount": 94,
"missingKeysCount": 4,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/trTR.ts/"
},
{
"languageTag": "uk-UA",
"importName": "ukUA",
"localeName": "Ukrainian",
"missingKeysCount": 7,
"totalKeysCount": 94,
"missingKeysCount": 9,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/ukUA.ts/"
},
{
"languageTag": "ur-PK",
"importName": "urPK",
"localeName": "Urdu (Pakistan)",
"missingKeysCount": 1,
"totalKeysCount": 94,
"missingKeysCount": 3,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/urPK.ts/"
},
{
"languageTag": "vi-VN",
"importName": "viVN",
"localeName": "Vietnamese",
"missingKeysCount": 9,
"totalKeysCount": 94,
"missingKeysCount": 11,
"totalKeysCount": 96,
"githubLink": "https://github.com/mui/mui-x/blob/-/packages/grid/x-data-grid/src/locales/viVN.ts/"
}
]
2 changes: 1 addition & 1 deletion docs/data/data-grid/sorting/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ A comparator determines how two cell values should be sorted.
Each column type comes with a default comparator method.
You can re-use them by importing the following functions:

- `gridStringOrNumberComparator` (used by the `string` and `singleSelect` columns)
- `gridStringOrNumberComparator` (used by the `string`, `singleSelect`, and `multipleSelect` columns)
- `gridNumberComparator` (used by the `number` and `boolean` columns)
- `gridDateComparator` (used by the `date` and `date-time` columns)

Expand Down
1 change: 1 addition & 0 deletions docs/pages/x/api/data-grid/data-grid-premium.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
"baseFormControl": { "default": "FormControl", "type": { "name": "elementType" } },
"baseIconButton": { "default": "IconButton", "type": { "name": "elementType" } },
"baseInputLabel": { "default": "InputLabel", "type": { "name": "elementType" } },
"baseMultipleSelect": { "default": "Autocomplete", "type": { "name": "elementType" } },
"basePopper": { "default": "Popper", "type": { "name": "elementType" } },
"baseSelect": { "default": "Select", "type": { "name": "elementType" } },
"baseSelectOption": { "default": "MenuItem", "type": { "name": "elementType" } },
Expand Down
Loading