Export to a file with a custom file name
Export to a file with a custom file name
dthemes
Posts: 11Questions: 6Answers: 0
Hi,
I tried to export DataTable data to a file with a custom file name. However, whatever I try the file name is always set to the title of the web page.
Please see my code below:
$.getJSON("http://127.0.0.1:9999/getdata", function( raw ) {
$(document).ready(function() {
$('#data').html( '<table cellpadding="0" cellspacing="0" border="0" class="display compact" id="foo-data"></table>' );
$('#foo-data').dataTable( {
dom: '<"tblContainerT"T><"tblContainerTop"lf><rt><"bottom"ip>',
sSwfPath: "/swf/copy_csv_xls_pdf.swf",
buttons: [
{
extend: 'excelFlash',
title: 'Data export'
}
],
data: raw['tbody'],
columns: raw['thead']
});
});
});
Cheers
This discussion has been closed.
Answers
bump
You are using both TableTools and Buttons in the above configuration. I would suggest not using TableTools at all.
Allan
Hi,
Ok I understand. But I don't know what you call "TableTools". Is the "dataTable" function ?
Don't use the
T
in thedom
parameter - that is TableTools. But theB
for buttons. See the Buttons documentation for defaults.Allan