This is a migrated thread and some comments may be shown as answers.

Remove trailing zeros when formatting decimals

1 Answer 922 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oleksii
Top achievements
Rank 1
Oleksii asked on 05 Feb 2015, 02:01 AM
Hi.

I have decimal values in my grid output and use "{0:N}" for column formatting. As a result it truncates everything after two decimal digits. This is good when it has those digits I do not need, for example 1.45286 -> 1.45. But when the value has less than two decimal digits it adds trailing zeros: 2 -> 2.00; 3.5 -> 3.50, and this is not what I want. Instead, I would prefer to keep them 2 & 3.5 respectively. The only thing I can change is to specify how many decimal digits I want to leave, but it will still keep those zeros if there are less digits in the value.

Is there a way to do it in Kendo?

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 06 Feb 2015, 03:08 PM

Hello Oleksii,

You can implement your own column.template in which you can execute your JavaScript function that will take care of this functionality. Here is some documentation that might be helpful:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.template

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Oleksii
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or