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

How I can cancel download file csv

Open christiantigre opened this issue 5 years ago • 5 comments

How I can cancel download

onDownload: (buildHead, buildBody, columns, data) => {
        // cancel here
      },
How can I cancel the file download, to use another file format

christiantigre avatar Sep 09 '19 14:09 christiantigre

I think you're looking for these options

image

which allow you to change the file name. I'm not sure cancelling the download is what you want, as that will stop it from occurring entirely.

gabrielliwerant avatar Sep 09 '19 19:09 gabrielliwerant

return false

dmp359 avatar Dec 27 '19 23:12 dmp359

Hello team, this is a portion of my code (which is weird but works with excel...)

    handleOnDownload(buildHead, buildBody, columns, data)  {
        let csvContent = buildHead(columns) + buildBody(data);
        var a = document.createElement('a');
        var textFileAsBlob = new Blob(["\ufeff",csvContent], {
            type: 'text/csv;charset=UTF-8',
            encoding: "UTF-8"
          });
        a.href = window.URL.createObjectURL(textFileAsBlob);
        a.download = 'exportCims.csv';
        a.click();
        return false;
    }

my option on my grid is

downloadOptions: {filterOptions : {useDisplayedRowsOnly : true}},
onDownload: (buildHead, buildBody, columns, data) => {this.handleOnDownload(buildHead, buildBody, columns, data)},

the return false does not work... ? (mui-datatable 3.7.3)

gmorisseau-dev avatar Dec 16 '20 15:12 gmorisseau-dev

Same problem with return false here:

	_onDownload = () => {
		console.log('_onDownload');
		return false;
	}

The file is still downloaded. Version 3.7.6

dreamfalcon avatar Apr 01 '21 10:04 dreamfalcon

I can confirm this is still an issue. (mui-datatables 3.7.7)

johanjq avatar Feb 10 '22 14:02 johanjq