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

[data grid] Commas in exported files are not handled correctly if value is in array #12945

Closed
z0d14c opened this issue Apr 29, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability feature: Export status: waiting for author Issue with insufficient information support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@z0d14c
Copy link

z0d14c commented Apr 29, 2024

Steps to reproduce

(Note: we are still on 6.x but as per the sandbox here it appears to happen in 7.x as well)

Link to live example: https://codesandbox.io/p/sandbox/cocky-haslett-kmw4hv?file=%2Fsrc%2FDemo.tsx%3A8%2C18

Steps:

  1. Have data that is in an array and has commas -- e.g. the value is ["Test1, Test2"]
  2. Use CSV export
  3. Notice that the outputted value takes up more columns than expected, messing up that row's column alignment

This is a case not handled by #1143

Current behavior

The outputted value takes up more columns than expected, messing up that row's column alignment

What you can do right now as a workaround is use the valueFormatter -- although this somewhat bothers me as it seems to potentially affect more than just the csv export functionaltiy
e.g. you can do this:

            valueFormatter: ({ value, ...rest }) => {
              if (Array.isArray(value)) {
                return value.reduce((prev, curr) => {
                  return prev + curr
                }, '')
              }
              return value
            },

Expected behavior

Would be great if this worked as expected without the workaround of using valueFormatter

Context

We have values for our grid that are in arrays. These values can have strings with commas in them. We need to be able to export this data in a way that doesn't break columns.

Your environment

I don't know that this matters -- you can see that it occurs in the sandbox shared above.

Search keywords: commas, csv, export, arrays
Order ID: 77204

@z0d14c z0d14c added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 29, 2024
@michelengelen
Copy link
Member

There is an option to use a different delimiter with the CSV export.
Here is an updated example to showcase that: Delimiter change on CSV export

Does that help you?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information component: data grid This is the name of the generic UI component, not the React module! feature: Export customization: extend Logic customizability support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 30, 2024
@michelengelen michelengelen changed the title [DataGrid] Commas in exported files are not handled correctly if value is in array [data grid] Commas in exported files are not handled correctly if value is in array Apr 30, 2024
Copy link

github-actions bot commented May 7, 2024

The issue has been inactive for 7 days and has been automatically closed.

@github-actions github-actions bot closed this as completed May 7, 2024
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! customization: extend Logic customizability feature: Export status: waiting for author Issue with insufficient information support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

2 participants