Datatables Export to Excel: how to use alternative cell source in export file.
Datatables Export to Excel: how to use alternative cell source in export file.
kaiaeberli
Posts: 11Questions: 1Answers: 2
Hi,
I have the following datatable, filled from a json string:
$('#' + idTable).DataTable({
columns: jsonData[0].columns,
data: jsonData[0].data,
"columnDefs": [{
"targets": "_all",
"className": "dt-right",
"render": {
"_": "data",
"display": "display"
}
}],
The json string contains both both a "display" and a "data" value for every cell:
var jsonData=
[
{
"data":
[
{
"header1": {"data": "abcde", "display": "abcde"}
, "header2": {"data": 0.0014466352336048006, "display": "0.0014"}
}
,
{
"header1": {"data": "abcde", "display": "abcde"}
, "header2": {"data": 0.0014466352336048006, "display": "0.0014"}
}
]
, "columns":
[
{"data": "header1", "title": "header1"}
, {"data": "header2", "title": "header2"}
]
}
]
Using TableTools, how can I export the "data" value to Excel (rather than the "display" value, which will be exported by default as it is shown in the table). The idea is to show floats in limited precision, but export full precision, without making another ajax call.
Thanks a lot,
Kai
This discussion has been closed.
Answers
anybody?
Seems that this issue was discussed already in 2012: https://datatables.net/forums/discussion/12063/mdata-mrender-and-ordering but as of April 2015 is still on the todo list: https://datatables.net/forums/discussion/27223/createdrow-in-conjunction-with-dynamic-column-visibility
For now I will go with adapting the Tabletools source code to look for 'filter'.