-
-
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
[DataGridPremium] Server-side data source with row grouping #13826
Conversation
Hi @MBilalShafi, are you able to provide an ETA for this? Thank you! |
Hey @tommy-wl, thank you for reaching out. The ETA for this feature is around the end of Q3, its currently one of the main focus areas for the team. Feel free to test the under development feature and provide some early feedback if you want. |
This comment was marked as outdated.
This comment was marked as outdated.
packages/x-data-grid-premium/src/hooks/features/rowGrouping/createGroupingColDef.tsx
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
packages/x-data-grid-premium/src/components/GridDataSourceGroupingCriteriaCell.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/hooks/features/rowGrouping/createGroupingColDef.tsx
Outdated
Show resolved
Hide resolved
7b7576f
to
ba0ab94
Compare
if (value === undefined) { | ||
return null; | ||
} |
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.
Not sure we should do this now, it's a breaking change (currently, undefined
value is treated as false
)
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 added it to avoid this:
For client-side row grouping we have a concept of autogenerated group nodes and we handle it like this:
mui-x/packages/x-data-grid/src/components/cell/GridBooleanCell.tsx
Lines 145 to 147 in ab4823d
if (params.field !== '__row_group_by_columns_group__' && isAutogeneratedRowNode(params.rowNode)) { | |
return ''; | |
} |
In server-side row grouping, all the rows are regular group rows and not marked as auto generated, so the above check doesn't work. Did a hacky'ish solution, let me know how does it feel.
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.
Solid feature! Great work!
@@ -252,6 +256,10 @@ Use the `setRowChildrenExpansion` method on `apiRef` to programmatically set the | |||
|
|||
{{"demo": "RowGroupingSetChildrenExpansion.js", "bg": "inline", "defaultCodeOpen": false}} | |||
|
|||
:::warning | |||
The `apiRef.current.setRowChildrenExpansion` method is not compatible with the [server-side tree data](/x/react-data-grid/server-side-data/tree-data/) and [server-side row grouping](/x/react-data-grid/server-side-data/row-grouping/). Use `apiRef.current.unstable_dataSource.fetchRows` instead. |
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.
Curious, why it is not compatible? Could it call the data source to apply the behavior or is there a strong feasibility blocker?
(Question applies to both get and set methods)
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.
Data source changes a bit how expansion works.
When the user expands a row, fetchRows
is called, which fetches the rows internally and only on success it calls setRowChildrenExpansion
internally which only updates the isExpanded
state of the respective rowNode
.
If the user tries to call setRowChildrenExpansion
there will be no rows to show, only the expand icon will shift to expanded form, thus setRowChildrenExpansion
is no longer recommended to use with the data source.
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.
Good point @joserodolfofreitas
@MBilalShafi Couldn't we potentially update setRowChildrenExpansion
to fetch rows if the data source is being used?
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 missed the conversation here.
Should we create an issue to make these approaches compatible?
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.
Couldn't we potentially update setRowChildrenExpansion to fetch rows if the data source is being used?
@cherniavskii We certainly could. Mostly a DX decision. It hasn't been done in the current implementation because setRowChildrenExpansion
sounds like (or anticipated as) a state setter (or a pure function), hiding the fetch
part behind would be less aligned with a user's expectation as it will now have 3 possible outcomes.
- Set the state right away (no data source)
- Set the state after some time (waiting time of the BE API)
- Never set the state (fetching failed)
Using it from within fetchRows
makes sense if it's understood to be only responsible for 1
, or we may have to change its current perception.
What do you think?
Co-authored-by: Armin Mehinovic <[email protected]>
@MBilalShafi great work! Super excited to start using this feature as soon as it is released! Quick question: just to confirm, does this work grouping multiple columns at the same time as well? https://mui.com/x/react-data-grid/row-grouping/#multiple-grouping-columns Thanks Premium customer - Support ID: 96081 |
Hey @tommy-wl,
Yes, single column and multiple column grouping both should work with this feature. |
π¨βπ» Ready for Review π¨βπ»
Part of #8179
Resolves #10859
Preview: https://deploy-preview-13826--material-ui-x.netlify.app/x/react-data-grid/server-side-data/row-grouping/
Action items
groupingValueGetter
useMockServer
:Follow-ups: