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] Fix support for singleSelect with numeric values #2112
Conversation
@@ -6,13 +6,14 @@ export const getGridSingleSelectOperators: () => GridFilterOperator[] = () => [ | |||
{ | |||
value: 'is', | |||
getApplyFilterFn: (filterItem: GridFilterItem) => { | |||
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already validating if there's a columnField
and operatorValue
before calling the filter function. Related to #1961 (comment)
packages/grid/_modules_/grid/components/panel/filterPanel/GridFilterInputValue.tsx
Show resolved
Hide resolved
@@ -74,7 +74,7 @@ export interface GridColDef { | |||
/** | |||
* To be used in combination with `type: 'singleSelect'`. This is an array of the possible cell values and labels. | |||
*/ | |||
valueOptions?: Array<any | { value: any; label: string }>; | |||
valueOptions?: Array<string | number | { value: any; label: string }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use GridCellValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we currently support options of type Date
(which is included in GridCellValue
)
It will be considered as an object here https://github.com/mui-org/material-ui-x/pull/2112/files#diff-e03ef6ac8071c6dbcd6ceddc294a6ceb9692826571ae45332126f34b953d35efR8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would I do a single select for a list of country for example, with the flag and country name?
I think the select options should consider renderCell, valueFormatter or getter...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's off topic: but I think this feature is a bit too basic at this stage and should consider renderCell, valueGetter, valueFormatter...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR add the support of number
, it's a step forward but I do agree that we still don't support everything we should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This singleSelect
is only a column type, like the others. The user can provide a custom cell or a different data structures.
Fixes #2111
Preview: https://deploy-preview-2112--material-ui-x.netlify.app/storybook/?path=/story/x-grid-tests-columns--single-select-column-type&globals=measureEnabled:false
Column "country" has as options
{ value: string; label: string }[]
Column "fruit" has as options
{ value: number; label: string }[]
Column "rating" has as options
number[]