This is a migrated thread and some comments may be shown as answers.
Error in formatNumber when using specific custom number format
5 Answers 42 Views
This is a migrated thread and some comments may be shown as answers.
Jaap
Top achievements
Rank 2
Jaap asked on 03 May 2012, 10:15 AM
Hello,

The formatNumber function gives an error when you try to format a number with a custom number format 0.####
The problem is that there are no zeros after the decimalseparator.
I have fixed it in the Kendo code, but not sure if I may post that here on the forum.

Also, looking to the code, I think there is an issue, when you have a number 1.23456 and you want to format it with 0.0##. You will get 1.23456 instead of 1.235.

Regards, Jaap

5 Answers, 1 is accepted

Sort by
0
Jaap
Top achievements
Rank 2
answered on 03 May 2012, 12:24 PM
Some other issues I found:

Formatting the number 4000 with 0,000.########## results in 04,000 while it should be 4,000
Formatting the number 300 with 0,000.########## results in 0300 while it should be 0,300

#,##0.######### works ok.
0
Georgi Krustev
Telerik team
answered on 07 May 2012, 01:06 PM
Hi Jaap,

 
Thank you for pointing these issues related with the custom numeric formatting. We addressed all of them and the fixes will be included in the service pack of KendoUI scheduled for the mid of May.
As a gratitude for your involvement I have updated your Telerik points.

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alexander
Top achievements
Rank 1
answered on 22 Mar 2013, 07:24 PM
Have these issues been fixed?
I am using v2012.3.14120.03019 and see the following behavior:

kendo.toString(0.06608, "n4") = 0.0661
kendo.toString(0.06608, "0.0000") = 0.0661
kendo.toString(0.06608, "#.####") = 0.06608
I expect this should be 0.0661.

kendo.toString(0.06608, "n3") = 0.066
kendo.toString(0.06608, "0.000") = 0.066
kendo.toString(0.06608, "#.###") = 0.06608
I expect this should be 0.066.

kendo.toString(0.0364, "n4") = 0.0364 
kendo.toString(0.0364, "0.0000") = 0.0364
kendo.toString(0.0364, "#.####") = 0.0364

kendo.toString(0.0364, "n3") = 0.036
kendo.toString(0.0364, "0.000") = 0.036
kendo.toString(0.0364, "#.###") = 0.0364
I expect this should be 0.036.

What I'm looking for is a way to format a number to always have less than or equal to four decimal places:
kendo.toString(0.06, x) = 0.06
kendo.toString(0.066, x) = 0.066
kendo.toString(0.0660, x) = 0.0660
kendo.toString(0.06608, x) = 0.0661
Is there a value I can use for x in this case?
0
Georgi Krustev
Telerik team
answered on 25 Mar 2013, 12:31 PM
Hello Alexsander,

 
I believe that all aforementioned formats work as expected. Check this jsBin demo for more information. To answer you question you can use "#.####" format.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alexander
Top achievements
Rank 1
answered on 25 Mar 2013, 01:37 PM
Georgi, thanks for the response. As you can see in this JSFiddle using Kendo v2012.3.1412 the "#.####" format does not result in the correct value. Your JSBin example uses v2013.1.319 so it appears this was an issue with the  earlier version of Kendo. Unfortunately I am not realistically able to upgrade Kendo as a solution at this point, so I'll have to find some other workaround. Thanks again.
Asked by
Jaap
Top achievements
Rank 2
Answers by
Jaap
Top achievements
Rank 2
Georgi Krustev
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or