Can I use maxDecimalPlaces to round a number instead of truncate.

Answered
Patrick OFriel asked on June 10, 2019

Hello, I have a column that should show only two decimal places and round the value when necessary.  For example, when a cell has the number '23.32678', it should display '23.33'. Here's an example in fiddle where it is just cutting off the extra decimal places https://jsfiddle.net/4z290g1p/ .

Is there a simple way to accomplish what I'm looking for? 

3 answers

Public
Christopher Phillips June 10, 2019

We also noticed when importing that dataset as a CSV the values round correctly

Public
Vera Didenko Vera Didenko Flexmonster June 11, 2019

Hello,
 
Thank you for writing to us.
 
We would like to point out that maxDecimalPlaces should round the numbers.
Our team is working on this and the fix will be available in the minor release of Flexmonster with the ETA 15th of July.
 
As a workaround, the decimalPlaces property can be used.
The decimalPlaces parameter specifies the exact number of decimals to show after the decimal separator. 
 
For example, 

formats: [
{ decimalPlaces: 2}
]

 
Here is a JSFiddle example for illustration.
 
Please let us know if this works for you.
 
You are welcome to contact us in case further questions arise.
 
Best Regards,
Vera

Public
Tanya Gryshko Tanya Gryshko Flexmonster July 16, 2019

Hello, Patrick, Christopher,
 
We are happy to let you know that the issue with rounding numbers when using maxDecimalPlaces was fixed.
 
This is provided in the 2.7.10 version of Flexmonster: https://www.flexmonster.com/release-notes/.
 
You are welcome to update the component.
Here is our updating to the latest version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/
 
Feel free to write to us in case of questions.
 
Best Regards,
Tanya

Please login or Register to Submit Answer