mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.15k stars 1.29k forks source link

[data grid] Support sorting on the `checkboxSelection` column #14952

Open xfsnowind opened 5 days ago

xfsnowind commented 5 days ago

The problem in depth

Hi,

Currently, the checkbox column does not support sort feature, which would make it easy for user to check the selected/unselected items.

I know it can be achieved by change the constant value GRID_CHECKBOX_SELECTION_COL_DEF

const GRID_CHECKBOX_SELECTION_COL_DEF_SORTABLE = {
  ...GRID_CHECKBOX_SELECTION_COL_DEF,
  sortable: true,
}

But then

  1. the checkbox column width would be too wide with the sort icon
  2. I assume this is more like a standard feature, data-grid lib should support it instead of being customized by user

So is it possible to have such a feature in the certain new release with a good UX design?

Your environment

`npx @mui/envinfo` ``` System: OS: macOS 15.0.1 Binaries: Node: 22.9.0 - ~/.nvm/versions/node/v22.9.0/bin/node npm: 10.8.3 - ~/.nvm/versions/node/v22.9.0/bin/npm pnpm: 9.9.0 - ~/Library/pnpm/pnpm Browsers: Chrome: 129.0.6668.91 Edge: 126.0.2592.81 Safari: 18.0.1 npmPackages: @emotion/react: 11.11.4 => 11.11.4 @emotion/styled: 11.11.5 => 11.11.5 @mui/icons-material: 6.1.1 => 6.1.1 @mui/lab: 6.0.0-beta.10 => 6.0.0-beta.10 @mui/material: 6.1.1 => 6.1.1 @mui/system: 6.1.1 => 6.1.1 @mui/types: 7.2.17 => 7.2.17 @mui/x-data-grid: 7.16.0 => 7.16.0 @mui/x-data-grid-generator: 7.16.0 => 7.16.0 @mui/x-data-grid-premium: 7.16.0 => 7.16.0 @mui/x-data-grid-pro: 7.16.0 => 7.16.0 @mui/x-date-pickers: 7.16.0 => 7.16.0 @mui/x-date-pickers-pro: 7.16.0 => 7.16.0 @mui/x-license: 7.16.0 => 7.16.0 @mui/x-tree-view: 6.17.0 => 6.17.0 @types/react: 18.3.2 => 18.3.2 react: 18.3.1 => 18.3.1 react-dom: 18.3.1 => 18.3.1 styled-components: 5.3.5 => 5.3.5 typescript: 5.6.2 => 5.6.2 ```

Search keywords: Checkbox sortable Order ID: 79531

MBilalShafi commented 5 days ago

Thanks @xfsnowind for the feature request. It makes sense to have been supported by the Data Grid internally. It's open for upvotes to check the demand in the community for us to prioritize it accordingly. Feel free to upvote the issue description.