decimalSize up to 15 instead of fixing it to 15 in datatable

in datatable, is it possible to keep decimalSize up to 15 instead of fixing it to 15 (remove trailing zeros)?

I found format: founction(val) {} in which val could have 14 decimals at maximum

You can use a custom formatting function, like next

var format = function(obj){
   var round = 1000000000000000;
   return Math.round(obj*round)/round
}

It will round up to 15 digits

format(0.1234567890123456789)
0.123456789012346

format(0.1234)
0.1234

the problem is that the value input to the format function is different than the value output from back end.

ex:

java backend output:

  1. 1.123456789012345

  2. 12.123456789012345

  3. 123.123456789012345

  4. 1234.123456789012345

  5. 12345.123456789012345

datatable format fn input:

  1. 1.123456789012345 (fine)

  2. 12.12345678901235 (wrong)

  3. 123.12345678901235 (wrong)

  4. 1234.1234567890124 (wrong)

  5. 12345.123456789011 (wrong)

change the Math.round to Math.floor, it will preserve the last digit

Please beware that javascript float has limited precision, so it will not be possible to have “15 digits after dot” precision for all types of numbers. For really big numbers you will need to use a server side formatting, or a separate lib for BigInteger handling. ( float numbers in Js can store 15-17 digits only, so if you have 4 digits before the dot, you can’t have 15 digits after dot )

got it, thanks a million