-
-
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
[core] Simplify the CSV export #2941
[core] Simplify the CSV export #2941
Conversation
@@ -15,6 +15,7 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF: GridColDef = { | |||
filterable: false, | |||
disableColumnMenu: true, | |||
disableReorder: true, | |||
disableExport: true, |
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.
This col was removed on clipboard export but not on regular CSV export
Do we agree that it should not be on any CSV export ?
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.
Hmm, I think I may have missed this in the print export logic 🤐 but yes I think it should be applied to any CSV export.
Update: ok i did remember to check this https://github.com/mui-org/material-ui-x/blob/next/packages/grid/_modules_/grid/hooks/features/export/useGridPrintExport.tsx#L75 😮💨
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 it, but it was removed twice, once in the clipboard export and one in serialiseRow
for any CSV export.
So it was in fact never exported on CSV.
I unified it and remove it in the buildCSV
method.
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.
And by adding disableExport
to the selection column, it will also hide it on the Print export 🥳
return buildCSV({ | ||
columns: exportedColumns, | ||
rows: visibleSortedRows, | ||
selectedRowIds: selection, | ||
rowIds: exportedRowIds, |
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 does look cleaner that way. Nice.
Extracted from #2725
buildCSV
method should not have to be aware of the selection of the Grid.useGridCsvExport
method inuseGridClipboard
to unify behavior (for instance the selection by checkbox column removal)rowIds = rowIds.filter((id) => selectedRowIds.includes(id))
was approaching a complexity ofn²