2 decimal & end by 0
2 decimal & end by 0
lenamtl
Posts: 265Questions: 65Answers: 1
Hi,
Why the latest 0 of 2 decimal value does not display?
50.50 will be displayed as 50.5
I'm filling the table using Ajax.
var dataSet = [
[ "Mydata", 52215, "95%", 50.50, -4.3, 7.2, "02" ],
]
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use a number renderer to define the output format.
Kevin
Hi,
How can I apply it to my actual code?
Allan
how can I get If number does not have decimal don't add 00
but if it have decimal show 2
50.50 will show 50.50
56 will show 56 not 56.00
See this thread with an example doing something similar.
Kevin
Hi,
let say I wan to check if integer no sure if this could work
var result = (n - Math.floor(n)) !== 0;
so how to apply if to a specific column
Check this SO thread for ways to check for an integer.
Like this:
Kevin
Sorry for the confusion
I know where to put the the render = it's working not like I expected but it working.
render: $.fn.dataTable.render.number( ',', '.', 2)
Now how can I apply the IF only on
"title": "test",
Not on all the column
All examples are based on data not on specific column
Did you look at the example in the thread I linked? You just need to change the if condition to match your requirements.
Kevin
Hi yes I have checked the example, but I'm not sure if I should use
render: function( data, type, row )
Is this the correct way to use it with my datatset?
Take a look at the
columns.render
docs to learn what the parameters mean. IF you want to check the value in that cell usedata
. If you want to check the value in another cell of the row userow
with the column index, for examplerow[1]
to get the second column.Looks correct. Did you try it?
Kevin