TableTools 2.1.4 and fnRender

TableTools 2.1.4 and fnRender

RupRup Posts: 8Questions: 0Answers: 0
edited February 2013 in TableTools
Hi,
I'm using DataTables 1.9.4 and TableTools 2.1.4 : really beautiful stuff.

Simple problem : to display numeric values as integers (no decimals), I have defined
[code]
"aoColumnDefs": [
{
"bUseRendered": false,
"fnRender": function ( o ) {
return o.oSettings.fnFormatNumber( parseInt( o.aData[ o.iDataColumn ] ) );
},
"aTargets": [ 7, 8 ]
}
]
[/code]

which works well.

However, when copying the table with TableTools Copy button, defined here
[code]
"oTableTools": {
"sSwfPath": "{!URLFOR($Resource.DataTables, 'extras/TableTools/media/swf/copy_csv_xls_pdf.swf')}",
"aButtons": [
{
"sExtends": "copy",
"bSelectedOnly": true
}
]
}
[/code]

the integer data gets copied with "." decimal point and 1 decimal digit (0).


How can I get integers formatted correctly before Copy ?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Firstly, don't use fnRender - it is decremented and will be removed in 1.10.

    Use mRender. And if you just want integers, all you need to do is:

    [code]
    {
    mRender: function ( data, type, row ) {
    return parseInt( data, 10 );
    },
    aTargets: [ 7, 8 ]
    }
    [/code]

    Assuming that the column position in the table is index 7 and 8, that should work. If not you need to specify mData for each column.

    Allan
  • RupRup Posts: 8Questions: 0Answers: 0
    Allan,
    Thanks for your great reactivity : your solution works, my problem is fixed.

    thanks again,
    Rupert
This discussion has been closed.