Difference direct function call buttons.exportData and exportOptions in initialisation
Difference direct function call buttons.exportData and exportOptions in initialisation

Hi,
I am initialising the export buttons within the datatable initialisation:
buttons: [
{
extend: 'excelHtml5',
text: "Excel Export",
filename: 'Export_EKPlanung',
footer: true,
exportOptions: {
format: {
header: function (data, columnIdx) {
console.log("Data" + data);
return data;
},
body: function (data, columnIdx, idx) {
var element = table
.cell(idx, columnIdx)
.node();
if ($(element).children().length > 0) {
return $(element).children().val();
} else {
return data;
}
}
},
stripHtml: true
}
}
]
Then the output of the console.log is e.g.:
Data<div class="DataTables_sort_wrapper">
Account<span class="DataTables_sort_icon"></span></div>
When I am using the function exportData:
table.buttons.exportData({
format: {
header: function (data, columnIdx) {
console.log("data:" + data);
return data;
},
body: function (data, columnIdx, idx) {
var element = table
.cell(idx, columnIdx)
.node();
if ($(element).children().length > 0) {
return $(element).children().val();
} else {
return data;
}
},
footer: function (data, columnIdx, idx) {
return data;
}
},
});
The console output is:
data:
Account
I am asking if this is a bug? Because I thougt exportOptions calls the function exportData. I use the 1.2.1 non-minified version.
Regards,
Denis
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Denis,
It looks like you are using jQuery UI styling, so if we take this example as a base - if I run:
on the console I get:
The HTML has not been stripped. Indeed, it shouldn't be in your second case above. I don't understand why it wouldn't be I'm afraid.
Do you have a page showing that problem?
Allan
Hi,
thanks for your fast reply. Unfortunately you can't access this site outside our network unless you connect via e.g. gotomeeting.
Edit: I deleted the bJQueryUI Option and it worked well with my first exmaple. The HTML is stripped.
Regards,
Denis
hmm - that's interesting! I would recommend not using that option, just import the jQuery UI styling integration and it will set the appropriate defaults. That option is going to be removed in the next major version of DataTables.
Allan