Get Free Trial

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

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 .

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

3 answers

Christopher Phillips June 10, 2019

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

Vera Didenko Vera Didenko Flexmonster June 11, 2019

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,

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:
You are welcome to update the component.
Here is our updating to the latest version guide for assistance:
Feel free to write to us in case of questions.
Best Regards,

Please login or Register to Submit Answer