TableTools 2.1.4 and fnRender
TableTools 2.1.4 and fnRender
Rup
Posts: 8Questions: 0Answers: 0
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 ?
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 ?
This discussion has been closed.
Replies
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
Thanks for your great reactivity : your solution works, my problem is fixed.
thanks again,
Rupert