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.

kaiaeberlikaiaeberli 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

Answers

This discussion has been closed.