Skip to content

Download to CSV function does not work if empty table values #434

@nick-youngblut

Description

@nick-youngblut

From the Customizing section of the docs:

customOpts = list(
      csv = list(
        name = "Download to CSV",
        callback = htmlwidgets::JS(
          "function (key, options) {
            var csv = csvString(this, sep=',', dec='.');

            var link = document.createElement('a');
            link.setAttribute('href', 'data:text/plain;charset=utf-8,' +
              encodeURIComponent(csv));
            link.setAttribute('download', 'data.csv');

            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
          }"
        )
      )
    )

This code does not work if any of the values in the rendered table are empty. The "Download to CSV" option is present in the menu, but clicking on it does nothing. If the user then completely fills all cells in the table with non-empty values, then the user can download the table as a csv.

This repo has not been updated in 2 years, so the docs likely won't be updated, but maybe a user has a suggestion on how to make the "Download to CSV" option more flexible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions