Custom formats with # and 0 in kendo.toString do not appear to work correctly. For example: kendo.toString(1234.5678, "#####") returns 12345 as shown in the demo example, but kendo.toString(12345678, "#####") returns 12345678. I would expect both snippets to return 12345. Also custom formats like ###-###-####, ## ## ##, #(###) ### ####, ##:##:##:## do not work, they just return an error or the original value. Any help would be greatly appreciated.
Thanks
Jonathan
Thanks
Jonathan
4 Answers, 1 is accepted
0
Hello Jonathan,
The "#" specifier does not limit the length of the number, which you try to format.
Currently, the kendo.toString method is not intended to format numbers using custom numeric formats, which have groups of numbers. If you need to format the number to look like a phone number, then you will need to use custom function, which do this.
Greetings,
Georgi Krustev
the Telerik team
The "#" specifier does not limit the length of the number, which you try to format.
Currently, the kendo.toString method is not intended to format numbers using custom numeric formats, which have groups of numbers. If you need to format the number to look like a phone number, then you will need to use custom function, which do this.
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
Jonathan
Top achievements
Rank 1
answered on 03 Jul 2012, 09:50 PM
Thank you Georgi! Creating a custom function to accomplish this is not a problem. However, If kendo.toString() is working as defined, I suggest that you update the documentation. It's a bit misleading. The definitions for how 0, #, literal string delimiters work under "globalization>custom numeric formats" imply that the kendo.toString() method supports the level of rich formatting I described. At least that's how I interpreted them :)
Best Regards,
Jonathan
Best Regards,
Jonathan
0
Kalli Kaldi
Top achievements
Rank 1
answered on 22 Feb 2016, 10:01 AM
Hello Georgi.
I hate to revisit an old thread like this one, but I'm having some problems creating a custom method to accomplish something similar to what Jonathan posted.
Can you give a code example on how to create a custom method to format a string ?
Best regards,
Karl
0
Hello Karl,
You will need to build a JavaScript function that takes a number value and outputs a string that matches your business requirements. The specific implementation falls out of the scope of the entitled support service.
I would suggest you ask your question in public forums like StackOverflow.
Regards,
Georgi Krustev
Telerik
You will need to build a JavaScript function that takes a number value and outputs a string that matches your business requirements. The specific implementation falls out of the scope of the entitled support service.
I would suggest you ask your question in public forums like StackOverflow.
Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!