How to format a number?
How to format a number?
Hi, i am new using DataTable and i am having a problem trying to format a number
my data has number like: 12000 , 8000, 133300 and i would like it be display like: 12.000, 8.000, 133.300 (or 12,000/8,000/133,300
i already formatted the number to display it the way i want, but after i formatted it, the number becomes a string, and the sorting stop working correctly.
i tried to used a plugin to formatted numbers, but still don't work. My question is: Is that a way to change a number from 12000 to 12.000 (or 12,000) and it keep been a number (not a string)?
Thanks
Answers
Hey you can use DatatTables built in number helper
https://datatables.net/manual/data/renderers#Number-helper
Thanks
Tom
Thank's for your answer Tom.
I am trying to use a plugin, but it does not work.. I am no sure if i am instaling it correctly
in one file i saved the plugin, called numeric-comma
and then i initiate the table as fallow:
$(document).ready(function() {
myTable = $('#tabela').DataTable({
"aoColumnDefs": [
{ "sType": "numeric-comma", "aTargets": [ 0 ] }
]
}
i dont know why this doesn't work, i even include a console.log() into the plugin, but it doesn't even read the plugin, because the console.log() dont show anything.
Is there any other configuration a should do??
Thanks
i am trying to use a plugin to sort correctly a formatted number like 123.456,78.. i just don't kown how to include it. I already tried to do in the following ways:
$.fn.dataTable.ext.type.order['numeric-comma-pre'] = function ( d )
$.extend( $.fn.dataTable.ext.type.order, {
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) {
Orthogonal data
But nothing works, i just dont know what to do
Thanks