Formatting decimal numbers ... again
Formatting decimal numbers ... again
gregraven
Posts: 6Questions: 0Answers: 0
I'm reading but not understanding, even though this must be really simple.
I have a data source that contains data that looks like this:
[code]
{
"aaData": [
[
"Wilson Hammertec 17",
"09/01/1993",
3.61,
3.12,
3.43,
3.64,
3.65,
0.00,
0.00,
3.66,
2.97,
3.48
]
]
}
[/code]
I call it with code that looks like this:
[code]
$(document).ready(function () {
$('#playtests').dataTable( {
"bProcessing": true,
"sAjaxSource": '/members/Scripts/playtest.js',
"bAutoWidth": false,
"sPaginationType": "two_button",
"iDisplayLength": 15,
"aoColumnDefs": [
{ "sClass": "center", "aTargets": [ 2,3,4,5,6,7,8,9,10,11 ] }
]
});
});
[/code]
Everything works perfectly. The problem is that in the decimal numbers in the resulting table are "reduced" down -- all the trailing zeros are gone. It's not a huge deal, but it makes the table look odd.
Is there a way of preserving the two-decimal-number format for my numerical columns?
I have a data source that contains data that looks like this:
[code]
{
"aaData": [
[
"Wilson Hammertec 17",
"09/01/1993",
3.61,
3.12,
3.43,
3.64,
3.65,
0.00,
0.00,
3.66,
2.97,
3.48
]
]
}
[/code]
I call it with code that looks like this:
[code]
$(document).ready(function () {
$('#playtests').dataTable( {
"bProcessing": true,
"sAjaxSource": '/members/Scripts/playtest.js',
"bAutoWidth": false,
"sPaginationType": "two_button",
"iDisplayLength": 15,
"aoColumnDefs": [
{ "sClass": "center", "aTargets": [ 2,3,4,5,6,7,8,9,10,11 ] }
]
});
});
[/code]
Everything works perfectly. The problem is that in the decimal numbers in the resulting table are "reduced" down -- all the trailing zeros are gone. It's not a huge deal, but it makes the table look odd.
Is there a way of preserving the two-decimal-number format for my numerical columns?
This discussion has been closed.
Replies
To preserve the content you need to make it into strings. DataTables will still sort it numerically.
Allan