mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

On download CSV trigger aditional function

Open Andy1408 opened this issue 7 years ago • 4 comments

For business rules, every time a user dowloads a CSV from a table, I need to record it in an rds instance, (just the user and the action, nothing about the file details or anything like that), so I was wondering if is it possible to trigger an aditional function when the user clicks in the download button.

Couldn't find anything usefull on the docs, nor in the issues. Thanks in advance

Andy1408 avatar Jan 18 '19 18:01 Andy1408

I'm proposing a new callback named onCSVDownload that would trigger when a user clicks the CSV download

gregnb avatar Jan 27 '19 16:01 gregnb

Could we also manipulate the data that goes to the CSV? Or, simpler, choose to have the input data go to the CSV instead of the rendered data? I have columns for memory where I render 2048 into 2,048 MB and my clients would like to have a CSV without the commas or letters

EDIT: It actually seems like my columns where I translate with commas / MB don't get exported as such. But I have columns which are rendered as more than just text (I pass in a <Typography> or a <LinearProgress> sometimes) and those end up in the excel as [object Object]

iKrushYou avatar Feb 06 '19 15:02 iKrushYou

I'm wanting an option for downloading all the data from the server instead of just the data on the page. And my data contains @material-ui/core/List components and these show up as [object Object] in the downloaded csv file.

allenjoy123 avatar Feb 06 '19 15:02 allenjoy123

Don't know if is the best or the desirable approach, but I made my own event, bind it in an IconButton onClick event and put it in the options customToolbar. Like this:

customToolbar: () => { return (<IconButton aria-label="download" onClick={() => this.handleDownload(this.state.data)}> <CloudDownload/> </IconButton> </Tooltip>) }

It looks like is part of the toolbar and does what is expected to. Only disadvantage is that you have to make download csv logic from scratch.

Hope it helps

Andy1408 avatar Feb 07 '19 23:02 Andy1408