Skip to content
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

Merged
merged 10 commits into from
Oct 22, 2021

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 22, 2021

Extracted from #2725

  • The buildCSV method should not have to be aware of the selection of the Grid.
  • Use useGridCsvExport method in useGridClipboard to unify behavior (for instance the selection by checkbox column removal)
  • Perf improvement when most of the rows are selected, rowIds = rowIds.filter((id) => selectedRowIds.includes(id)) was approaching a complexity of

@flaviendelangle flaviendelangle added core Infrastructure work going on behind the scenes component: data grid This is the name of the generic UI component, not the React module! labels Oct 22, 2021
@flaviendelangle flaviendelangle self-assigned this Oct 22, 2021
@@ -15,6 +15,7 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF: GridColDef = {
filterable: false,
disableColumnMenu: true,
disableReorder: true,
disableExport: true,
Copy link
Member Author

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 ?

Copy link
Member

@DanailH DanailH Oct 22, 2021

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 😮‍💨

Copy link
Member Author

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.

Copy link
Member Author

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,
Copy link
Member

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.

@flaviendelangle flaviendelangle changed the title [core] Simplify the CSV export row id list generation [core] Simplify the CSV export Oct 22, 2021
@flaviendelangle flaviendelangle merged commit 3adb29b into mui:next Oct 22, 2021
@flaviendelangle flaviendelangle deleted the csv-export-row-ids branch November 9, 2021 07:49
@flaviendelangle flaviendelangle mentioned this pull request Nov 12, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants