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] List View #14393

Merged
merged 54 commits into from
Oct 17, 2024
Merged

[DataGrid] List View #14393

merged 54 commits into from
Oct 17, 2024

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Aug 30, 2024

Preview: https://deploy-preview-14393--material-ui-x.netlify.app/x/react-data-grid/list-view/

Based on https://www.notion.so/mui-org/x-grid-Mobile-view-for-Data-Grid-b6228123c8a64352ba2c355c46e4e4ff

Also fixes #14922

TODO

  • Reset horizontal scrolling on mode change
  • Row selection (with copy ability – pasted values are pasted as columns)
  • Sorting (and muti-sort) works
  • Filtering works
  • Pinned rows
  • Actions column
  • Editing
  • Sorting controls in the toolbar
  • Column visibility / field visibility
  • Should the pinned columns stay in mobile view? No, it doesn't make much sense
  • Better naming for the feature? Users might use it on large screens. Perhaps call it "single-column view" or "card list view"?
  • Fix keyboard navigation
  • Fix keyboard selection
  • Make it a Pro feature
  • Hide the toolbar in the demo
  • Add a checkbox/toggle for manual switching between normal view and list view
  • Fix the render context issue when switching between list view and normal view @cherniavskii
  • Add a link to a working codesandbox demo
  • Update the data grid version in the codesandbox demo once we release the feature

Not doing

  • Row reordering
  • Checkbox selection
  • Should Export have a special treatment in mobileView?
  • Master detail

Follow up issues

@cherniavskii cherniavskii added the component: data grid This is the name of the generic UI component, not the React module! label Aug 30, 2024
@mui-bot
Copy link

mui-bot commented Aug 30, 2024

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

Updated pages:

Generated by 🚫 dangerJS against 2dd1294

Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that approach ... definitely worth exploring this a bit more IMO. 💙

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 20, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@oliviertassinari oliviertassinari added mobile Targets mobile platform plan: Pro Impact at least one Pro user labels Sep 26, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 1, 2024
@KenanYusuf KenanYusuf changed the title [DataGrid] PoC: mobile view [DataGrid] \ Oct 1, 2024
@KenanYusuf KenanYusuf changed the title [DataGrid] \ [DataGrid] Single-Column View Oct 1, 2024
@KenanYusuf KenanYusuf changed the title [DataGrid] Single-Column View [DataGrid] List View Oct 3, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 9, 2024
Copy link

github-actions bot commented Oct 9, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@KenanYusuf KenanYusuf self-assigned this Oct 10, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 10, 2024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the motivation behind having the list view column definition in the state?
I'm not saying it's wrong, but I'm curious if there are any benefits to it compared to consuming it from the prop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a few places, e.g. useGridVirtualScroller and useGridScroll, we need all of the visible columns. In some of those places it is expecting the visible columns to have a computedWidth property, which doesn't exist on the list column definition by itself. Before we were just calculating this at the point of rendering the cell (in GridRow.tsx), but it made sense to me that we calculate it once and store it in state so that every time we need the list of visible columns, it has the computedWidth. Perhaps there is another way to satisfy this that I didn't consider...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not having this as a new data set in the generator?

return [
...data.columns,
{
type: 'actions',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is strange that using list view and list column you get actions still from the regular columns

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cherniavskii thoughts on this? I wonder if listColumn should become listColumns, and we require users to specify actions for list view and regular view separately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this too. It totally makes sense for the actions column use case, especially for the ListViewAdvanced demo.
But should we limit the number of items in listColumns to 2? And how do we distribute the width between them? Any ideas?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided not to persist the actions column, and make actions part of the list view cell instead.
This way, the list view cell always takes 100% of the width.
Done in 034c355 (#14393)

*/
export type GridListColDef<R extends GridValidRowModel = any, V = any, F = V> = Pick<
GridBaseColDef<R, V, F>,
'field' | 'renderCell' | 'align' | 'cellClassName' | 'display'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why these are being picked up.
in the example only field and renderCell are being used.
is there plan to support this in a more out-of-box way where you might not need custom renderer for simple use cases?

});
};

const prevInnerWidth = React.useRef<number | null>(null);
Copy link
Contributor

@romgrk romgrk Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to initialize the ref with a number value instead? It makes the typing more simple, and keeps code paths that use this value monomorphic. -1 seems like it could be a good candidate. If this value is sometimes a float, then NaN can also be a good initial value.

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! feature: List view Related to the data grid liist view feature mobile Targets mobile platform plan: Pro Impact at least one Pro user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] autosizeColumns on columnVisibilityModelChange fails
9 participants