TableExport icon indicating copy to clipboard operation
TableExport copied to clipboard

Download function for custom buttons when exportButtons is false

Open othmoz opened this issue 7 years ago • 2 comments

Hi, Thanks for your work on this plugin, I'd like to generate the export buttons myself, I have set exportButtons to false and have made my buttons the way I want them, however I searched the docs and didn't find the function to call on the click event to download the data ?

Any help is appreciated

othmoz avatar Jan 17 '18 13:01 othmoz

Try this:

var instance = $("#ranklist-table").tableExport({
	formats: ['xlsx'],
	exportButtons: false
});
var exportData = instance.getExportData()['ranklist-table']['xlsx'];
$("#export-ranklist").click(function () {
	instance.export2file(exportData.data, exportData.mimeType, exportData.filename, exportData.fileExtension);
});

dreamerblue avatar Jan 19 '18 10:01 dreamerblue

I like the solution. However, it does not work for dynamical tables. Basically replacing the event code with

$("#export-ranklist").click(function () {
       instance.reset();
	instance.export2file(exportData.data, exportData.mimeType, exportData.filename, exportData.fileExtension);
});

just does not work. I think that it might be connected with #99.

fretchen avatar May 30 '18 17:05 fretchen