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] Show label on the filter tooltip #15933

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

good-jinu
Copy link
Contributor

@good-jinu good-jinu commented Dec 19, 2024

Closes #5492

How it currently works

Here's the example code

import * as React from 'react';
import {DataGrid, GridToolbarFilterButton} from '@mui/x-data-grid';

export default function ConditionalValidationGrid() {
    return (
        <DataGrid
            filterModel={{
                items: [{field: 'status', operator: 'isAnyOf', value: ['Status 0', 'Status 1']}],
            }}
            rows={[
                {id: 0, status: 'Status 0'},
                {id: 1, status: 'Status 1'},
                {id: 2, status: 'Status 2'},
            ]}
            columns={[
                {
                    field: 'status',
                    type: 'singleSelect',
                    valueOptions: [
                        {label: 'pending', value: 'Status 0'},
                        {label: 'success', value: 'Status 1'},
                        {label: 'error', value: 'Status 2'},
                    ],
                },
            ]}
            slots={{toolbar: GridToolbarFilterButton}}
        />
    );
}

When mouse goes over Filter button, It shows the tooltip
스크린샷 2024-12-19 오후 1 12 14

The tooltip shows the value (Status 0,Status 1), while people most likely expecting to see the label (pending,success).

스크린샷 2024-12-19 오후 1 12 30

Since It shows the label for other spaces, It makes sense to show label rather than the value.

How It changed

스크린샷 2024-12-19 오후 1 11 56

I've modified the getValueAsString function to use label instead of value for the singleSelect type

When valueOptions is given with label, The tooltip shows the label.



Given the function name getValueAsString, I'm not entirely sure if passing label is the best approach.

@good-jinu good-jinu changed the title [dataGrid] Show label on the filter tooltip [DataGrid] Show label on the filter tooltip Dec 19, 2024
@mui-bot
Copy link

mui-bot commented Dec 19, 2024

Deploy preview: https://deploy-preview-15933--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 43e5ac7

@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Format value shown in the filter button tooltip
3 participants