Issue 546 - Visible columns and data misalignment in export#592
Issue 546 - Visible columns and data misalignment in export#592Marc-Andre-Rivet merged 4 commits intodevfrom
Conversation
| {col1: 1, col2: 2, col3: 3} | ||
| { col1: 1, col2: 2, col3: 'x', col4: 3 }, | ||
| { col1: 2, col2: 3, col3: 'x', col4: 4 }, | ||
| { col1: 1, col2: 2, col3: 'x', col4: 3 } |
There was a problem hiding this comment.
Add one unused (hidden) column to the dataframe
| B3: {t: 'n', v: 3}, | ||
| B4: {t: 'n', v: 2}, | ||
| C1: {t: 's', v: 'col3'}, | ||
| C1: {t: 's', v: 'col4'}, |
There was a problem hiding this comment.
Changed col3 for col4 above
|
The poster in #546 thought the correct behavior should be to show all columns, hidden or not. This PR results in the export correctly matching what's displayed, which sounds like a reasonable default, but perhaps to make everyone happy we need to support either option somehow? |
|
I think I misunderstood the poster's meaning. I still think the correct default behavior is to ignore hidden columns. (1) we already replicate the view’s content when it comes to sorting and filtering My suggestion is to expand on the As we did elsewhere, leaving the basic usage simple but presenting a more complex prop for tweaking / advance usage. This should be simple enough to support, and could be folded in with the fix. |
|
Whether to include all or just visible columns doesn't really fit under the prop |
|
Fair enough. My attempts to minimize props were ill advised. |
- new export_columns prop - change export logic to export all columns if desired - additional typing - typo fix - changelog entry
| const { columns, export_columns, export_format, virtual_data, export_headers, visibleColumns, merge_duplicate_headers } = props; | ||
| const isFormatSupported = export_format === ExportFormat.Csv || export_format === ExportFormat.Xlsx; | ||
|
|
||
| const exportedColumns = export_columns === ExportColumns.Visible ? visibleColumns : columns; |
There was a problem hiding this comment.
Use either visible columns or all columns depending on the prop setting
| interface IExportButtonProps { | ||
| columns: Columns; | ||
| export_format: string; | ||
| export_columns: ExportColumns; |
There was a problem hiding this comment.
Updated string usage to enums
| } | ||
|
|
||
| export function transformMultDimArray(array: (string | string[])[], maxLength: number): string[][] { | ||
| export function transformMultiDimArray(array: (string | string[])[], maxLength: number): string[][] { |
| {col2: 2, col3: 3} | ||
| {col2: 2, col4: 3}, | ||
| {col2: 3, col4: 4}, | ||
| {col2: 2, col4: 3} |
There was a problem hiding this comment.
col3 became col4 above
alexcjohnson
left a comment
There was a problem hiding this comment.
Very nice. Just the one comment about the changelog, then 💃
Fixes #546