-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Add columnGroupingModel
#5133
Conversation
These are the results for the performance tests:
|
51ff034
to
ee623e4
Compare
About vitualization: Before/after the first/last rendered column, I loop on other visible as long as they extend the first/last group of a given header row. This allows to render groups that always have the correct width: Virtualization can be tested here: 100 columns grouped according to their binary expression |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
After speaking with @joserodolfofreitas, how do we feel about something along these lines to show column grouping (grouping by text size + border-bottom)? This would require having the column separator appear on hover to avoid feeling too overcrowded and busy. Separator on hover — header rowSeparator on hover — column group row 1Separator on hover — column group row 1 |
882a701
to
dab238f
Compare
@gerdadesign About the I've updated the codesandbox such that you can experiment with the different density factors |
@m4theushw I was looking at the I was not the case before:
Is their a specific reason for that or can I modify all the tests to let them match the new behavior (include header in the rowcount)? |
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.
Great work so far. I think that columns not belonging to a named column group should belong to an empty group, so the column headers styling is consistent. It appears to be how AG Grid works: https://plnkr.co/edit/8TQhvj4m6obGYy2T?open=main.js
packages/grid/x-data-grid/src/hooks/features/columns/useGridColumnGrouping.ts
Outdated
Show resolved
Hide resolved
> | ||
{depthInfo.elements.map(({ groupId, width, fields, colIndex }, groupIndex) => { | ||
return ( | ||
<GridColumnGroupHeader |
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.
Could GridColumnHeaderItem
be reused to have the same styling? We could add props to make it not clickable.
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.
It's possible but it will be a bit hacky, because GridColumnHeaderItem
infers a lot of properties from column
so I will have to provide a column
props faking the column state from the parameters of the grouping model.
I'm also concerned by the number of conditions to introduce in GridColumnHeaderItem
to support the two types of headers.
For example data-field
becomes data-fields
to be able to have a smooth resizing
The resizing function of a group will probably be different from the resizing of a column because for a column on each mouseMove
we can get the difference before/after and apply the 2px
modification to all cells.
But when a column group containing 4 columns is resized by 1px
I'm not sure we can modify all rows by 0.25px
When introducing a collapsed/extended cell it will be new action buttons to set
Could it be possible to keep GridColumnHeaderItem
and GridColumnGroupHeaderItem
with their own interfaces and internal logic, but reuse the same styled-components in both such that we kept a unified style, but have custom props/logic adapted for each case
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 tried something by introducing <GridGenericColumnHeader />
the two components GridColumnHeaderItem
and GridColumnGroupHeader
are now kind of wrapper, that adapt their props to the GridGenericColumnHeader
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 think the current approach is good. I'm most concerned about reusing the same class names.
I see
Yeah, according to the example in https://w3c.github.io/aria-practices/examples/grid/dataGrids.html#ex3_label the row count should include the headers. I don't know why this was left. |
@m4theushw About putting columns that do not belong to a group in the grouping model I do not understand what is the usecase. For AG grid, I understand, because grouping is defined in the So if a column does not appear in the grouping, by default it has no group |
It won't have any functionality, it's more if users want to always show the bottom border, then have like a vertical separator to separate the groups. The way it was done here the border is in the groups. This can also be achieved with CSS. |
2c68c04
to
22782a0
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
Apart from few minor suggestions, looks good to me 👍
packages/grid/x-data-grid-pro/src/hooks/features/columnReorder/useGridColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-data-grid/src/components/columnHeaders/GridColumnGroupHeader.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-data-grid/src/hooks/features/columnGrouping/useGridColumnGrouping.ts
Outdated
Show resolved
Hide resolved
packages/grid/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-data-grid/src/hooks/features/density/useGridDensity.tsx
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
isResizing={false} | ||
sortDirection={null} | ||
hasFocus={false} | ||
tabIndex={0} |
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.
The column group headers don't have keyboard navigation with the arrow keys, but with tabIndex=0
we can navigate with Tab between them. This is breaks the idea of only-one-focusable-element-per-grid from https://www.w3.org/WAI/ARIA/apg/patterns/grid/. I think they should be non-interactive.
tabIndex={0} | |
tabIndex={-1} |
Was there a decision made for the default group header size? If we plan to support filtering, sorting, and other actions available in the column menu, should we consider match the header height? |
@gerdadesign With the current space, seems that buttons can fit in the smaller height In The choice is between:
About the menu, I do not think it will be as important as the column menu. In a group, filtering and sorting is not intuitive. The only action I found is group expansion which allows hiding/showing multiple columns on a single click, here is the AG-Grid example about sport results |
Co-authored-by: Flavien DELANGLE <flaviendelangle@gmail.com> Co-authored-by: Danail Hadjiatanasov <hadjiatanasov@gmail.com> Co-authored-by: Matheus Wichman <matheushw@outlook.com> Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com> Co-authored-by: José Rodolfo Freitas <joserodolfo.freitas@gmail.com> Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@alexfauquette Should we update these or is the idea to wait for having more of the column header group features? |
Just checked with @joserodolfofreitas we can mark them as done. I'm opening the PR |
@alexfauquette Awesome thanks, I linked the other PRs to this one so it's easier to understand the history. @mui/xgrid On different notes, I landed on this page https://next.mui.com/x/react-data-grid/column-groups/ and noticed a few things, maybe for future follow-ups:
vs. https://mui.com/x/react-data-grid/column-groups/#BasicGroupingDemo.tsx, more inlined with https://mui.com/material-ui/react-table/#column-grouping, it feels better, but it's not awesome either. |
Fix #195
columnGroupingModel
to manage the tree of column groupsrole="columnheader"
and correct column spanningdocs preview: https://deploy-preview-5133--material-ui-x.netlify.app/x/react-data-grid/column-groups/
with default style: https://codesandbox.io/s/basicgroupingdemo-demo-mui-x-forked-6vhr5j?file=/demo.tsx
with show right border style (it seems buggy when the total width is smaller than the container width): https://codesandbox.io/s/basicgroupingdemo-demo-mui-x-forked-7si9wc?file=/demo.tsx
performance demo: https://codesandbox.io/s/basicgroupingdemo-demo-mui-x-forked-fj4qcs?file=/demo.tsx
Changelog
You can now group columns by using the
columnGroupingModel
prop. This allows you to display more structured data.To enable this feature, add
experimentalFeatures={{ columnGrouping: true }}
.The grouping header can be fully customized.
See the documentation to explore everything it has to offer.