-
-
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
[data grid] Print export fails when footer is set to hidden #13015
Comments
Hey @sambbaahh and thanks for raising this issue. It happens because the selector is not returning an element, since we do not render it when using the With this diff it can be fixed: diff --git a/packages/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx b/packages/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx
index 5ba08b587..7f9805da8 100644
--- a/packages/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx
+++ b/packages/x-data-grid/src/hooks/features/export/useGridPrintExport.tsx
@@ -183,9 +183,11 @@ export const useGridPrintExport = (
const gridFooterElement: HTMLElement | null = gridClone.querySelector(
`.${gridClasses.footerContainer}`,
);
- gridFooterElement!.style.position = 'absolute';
- gridFooterElement!.style.width = '100%';
- gridFooterElement!.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
+ if (gridFooterElement) {
+ gridFooterElement.style.position = 'absolute';
+ gridFooterElement.style.width = '100%';
+ gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
+ }
// printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
// prevents us to do it Since this is a relatively small fix I will open this up for the community to work on it. |
@sambbaahh: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
@MBilalShafi / @michelengelen Hi, from which version of @mui/x-data-grid-premium this fix is available? |
Hey guys, I have the same issue using mui pro. I checked the work/branch hasn't merged into main. Could you please advise? |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/react-xezygx?file=Demo.jsx
Steps:
Current behavior
An error is displayed in the console:
"
Error in /turbo_modules/@mui/x-data-grid@7.3.2/node/hooks/features/export/useGridPrintExport.js (136:23)
Cannot read properties of null (reading 'style')
"
Expected behavior
Print all the rows that are in the datagrid and hide footer
Context
I am trying to hide the footer in the print export. But
hideFooter: true
breaks the data grid. And when set to false, it works as expected.This error appeared after updating to the latest version. Before I was using version 6.11.1 and it worked.
Your environment
npx @mui/envinfo
Search keywords: print export
The text was updated successfully, but these errors were encountered: