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

[data grid] Remove Empty String Option in MUI DataGrid SingleSelect Filter #12611

Closed
hamzasial1911 opened this issue Mar 28, 2024 · 4 comments
Closed
Labels
component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Filtering Related to the data grid Filtering feature

Comments

@hamzasial1911
Copy link

hamzasial1911 commented Mar 28, 2024

Summary

The current implementation of the MUI DataGrid SingleSelect filter includes an empty string option alongside values, which may not align with user expectations. This enhancement aims to remove the empty value from the filter dropdown and empower users to manually add custom values for a more tailored filtering experience.

Examples

Screenshot 2024-03-28 at 9 45 36 AM

Current:
I am getting this empty value even after giving the: optionalValues: ["Open","PartiallyFilled","Filled", "Rejected"]

Expected
I dont want to see the empty value in the dropdown.

Motivation

  • Improve user experience by eliminating the empty string option in the SingleSelect filter.

  • Enable users to manually add custom values, enhancing the filter's customization capabilities.

  • Streamline the filtering interface by focusing on user-driven input without the distraction of an empty value.

Search keywords:

@hamzasial1911 hamzasial1911 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 28, 2024
@zannager zannager transferred this issue from mui/material-ui Mar 29, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Mar 29, 2024
@michelengelen
Copy link
Member

@mui/xgrid do we support this through some filter customization? I did try using requiresFilterValue on the FilterOperator, but that did not work.

@michelengelen michelengelen changed the title Enhancement Request: Remove Empty String Option in MUI DataGrid SingleSelect Filter [data grid] Remove Empty String Option in MUI DataGrid SingleSelect Filter Apr 2, 2024
@michelengelen michelengelen added feature: Filtering Related to the data grid Filtering feature enhancement This is not a bug, nor a new feature labels Apr 2, 2024
@MBilalShafi
Copy link
Member

Hi @hamzasial1911!

The purpose of the empty value is to allow the users to be able to clear the value from the dropdown.

You can change the behavior by customizing the component used as the InputComponent in the respective colDef.filterOperators entry.
I tried to do this in this example for the status column: https://stackblitz.com/edit/react-97fkmt

Let me know if this is what you are looking for.

@MBilalShafi MBilalShafi added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 3, 2024
@hamzasial1911
Copy link
Author

@MBilalShafi Great work! This is exactly what I want.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Apr 7, 2024
Copy link

github-actions bot commented Apr 7, 2024

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@hamzasial1911: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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! enhancement This is not a bug, nor a new feature feature: Filtering Related to the data grid Filtering feature
Projects
None yet
Development

No branches or pull requests

4 participants