-
-
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
How can i print only selected rows in my MUI DataGrid pro? #9824
Comments
Hi @bogdancbs Could you clarify, what your expectations are for Print export in the following scenarios:
Thanks! |
Hello, @cherniavskii
thanks. |
@bogdancbs It seems there another issue talking about the same thing: #9993 Thanks |
I have just updated my PR that @MBilalShafi mentioned and that will fix this issue. Hopefully that will be reviewed and merged in shortly. |
works great! thnx |
Hello @MBilalShafi, any new updates when it will be merged? |
@bogdancbs there's still discussion on the PR, feel free to go over to it and leave your input about why this feature should be included and whether or not the current behavior is expected. I personally found it confusing that the print export does not export only selection as that's the behavior of all other export options. |
@bogdancbs the PR has been merged and will be included in the next release (6.15.0) which should be sometime in this upcoming week. Stay tuned! Also note that to prevent breaking changes it will still export all rows by default, but now there is a solution/workaround to export only selected rows via print. An example of how to do this has been added to the documentation which you'll be able to find under this section once it goes live. |
Thank you! Looking forward to test. |
Yes, it should be available in the next release. Until then, if you want, you can experiment with the API. Here's the API documentation link for the PR: https://deploy-preview-10084--material-ui-x.netlify.app/x/react-data-grid/export/#customizing-the-rows-to-export Feel free to check it out and possibly share some feedback! |
@bogdancbs it's been released! The latest version 6.15.0 has this new feature. Here's a link to the documentation showing how to export only selected rows via print. |
@zreecespieces thank you, i will look in to it to see how i can use |
i don't understand what i'm doing wrong.
here is the custom component CustomGridToolbarContainer:
); and const getSelectedRowsToExport return gridFilteredSortedRowIdsSelector(apiRef); and |
@bogdancbs It doesn't look like you're passing the
If you're still having trouble please create a codesandbox with a basic recreation of this for me to help you troubleshoot. |
@zreecespieces Thank you!! it worked! |
@bogdancbs Awesome! I'm glad to be able to help you get this feature working in your application! |
@zreecespieces i just realized that my context menu after adding slots and slots props dose not work anymore. Is there another way?
|
@cherniavskii hello, can you help me? |
@bogdancbs You should pass a React component with a stable reference to the |
@cherniavskii thanks, i used solts only instead of components and now it works. Thanks |
This is odd, just changing components to slots shouldn't make a difference. But it's good to hear that the issue is resolved 👍 |
Order ID or Support key 💳 (optional)
68255
Duplicates
Latest version
The problem in depth 🔍
I have a mui datagrid pro table and now when i export to print it prints all rows. How can i print only selected rows (checkbox).
If table is filtered it prints filtered ones, it's ok, but if i select it prints all.
` <DataGridPro
rows={dosare}
onRowHover={handleRowHover}
checkboxSelection
checkboxSelectionVisibleOnly={true}
disableSelectionOnClick={true}
onSelectionModelChange={(ids) => {
const selectedIDs = new Set(ids);
const selectedRows = dosare.rows.filter((row) =>
selectedIDs.has(row.id),
);
setSelectedRows(selectedRows);
}}
onRowSelectionModelChange ={handleSelectionModelChange}
onFilterModelChange={handleFilterChange}
columns={columns}
pageSize={20}
rowsPerPageOptions={[10, 20, 50, 100]}
pagination
paginationMode="client"
loading={loadingIndicator}
components={{
Your environment 🌎
`npx @mui/envinfo`
System: OS: Windows 10 10.0.22621 Binaries: Node: 14.21.3 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.18 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 114.0.5735.248 Edge: Spartan (44.22621.2070.0), Chromium (115.0.1901.183) npmPackages: @emotion/react: ^11.10.6 => 11.11.1 @emotion/styled: ^11.10.6 => 11.11.0 @mui/base: 5.0.0-beta.4 @mui/core-downloads-tracker: 5.14.0 @mui/icons-material: ^5.11.11 => 5.13.7 @mui/lab: ^5.0.0-alpha.133 => 5.0.0-alpha.134 @mui/material: ^5.14.0 => 5.14.0 @mui/private-theming: 5.13.7 @mui/styled-engine: 5.13.2 @mui/styled-engine-sc: ^5.11.11 => 5.12.0 @mui/styles: ^5.14.1 => 5.14.1 @mui/system: 5.13.5 @mui/types: 7.2.4 @mui/utils: 5.13.1 @mui/x-data-grid: ^6.0.1 => 6.9.2 @mui/x-data-grid-pro: ^6.6.0 => 6.8.0 @mui/x-license-pro: 6.6.0 @types/react: 18.2.14 react: ^18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 styled-components: ^5.3.9 => 5.3.11The text was updated successfully, but these errors were encountered: