-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Grouping
+ Column Group
cause runtime error
#8492
Comments
After clicking in the button to ungroup the column, the next render is still considering the grouped column so it fails. The following diff fixes this problem, although we might need to improve the support for grouping columns that are also part of a column group, because it doesn't seem right to see the column twice. diff --git a/packages/grid/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx b/packages/grid/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx
index 58d8ba549..9fd40f5b6 100644
--- a/packages/grid/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx
+++ b/packages/grid/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx
@@ -396,9 +396,11 @@ export const useGridColumnHeaders = (props: UseGridColumnHeadersProps) => {
0,
firstVisibleColumnIndex,
);
const leftOverflow = hiddenGroupColumns.reduce((acc, field) => {
const column = apiRef.current.getColumn(field);
- return acc + (column.computedWidth ?? 0);
+ return acc + (column?.computedWidth ?? 0);
}, 0);
let columnIndex = firstColumnToRender;
@@ -417,7 +419,7 @@ export const useGridColumnHeaders = (props: UseGridColumnHeadersProps) => {
const headerInfo: HeaderInfo = {
groupId,
width: columnFields
- .map((field) => apiRef.current.getColumn(field).computedWidth)
+ .map((field) => apiRef.current.getColumn(field)?.computedWidth)
.reduce((acc, val) => acc + val, 0),
fields: columnFields,
colIndex: columnIndex, |
Hi, I have the same issue. Are you still working on a solution? |
@m4theushw Is that patch good to be applied as-is? |
Any updates about this issue? I got the same trouble and i'm stuck with this right now |
I think you could submit a PR with the patch above. The task is in our backlog so we'll get around to it at some point soon-ish. |
I'm also waiting for this fix. Thanks. |
For anyone else coming here, the current version at the time of this is "@mui/x-data-grid-premium": "^6.16.2", the fix for us was just to send it an empty column, i.e. TableColumn.name_of_your_column('name_of_your_group_field', ''); This seems to have gotten rid of the error. |
Hi @jonathaneemmett , could you share a screenshoot about the example that you said before?. It would be very useful if it's works. Thanks. |
Is this issue still reproducible? |
The issue has been inactive for 7 days and has been automatically closed. If you think that it has been incorrectly closed, please reopen it and provide missing information (if any) or continue the last discussion. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/datagrid-forked-s9np3z
Steps:
Screen.Recording.2023-04-03.at.16.11.19.mov
Current behavior 😯
throw runtime exception
Expected behavior 🤔
no exception
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
Order ID or Support key 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: