kendo.toString not working as expected

5 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    10 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post

    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
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 03 Jul 2012 Link to this post

    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
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Jonathan
    Jonathan avatar
    10 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2012 Link to this post

    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
  5. Kalli Kaldi
    Kalli Kaldi avatar
    27 posts
    Member since:
    Oct 2011

    Posted 22 Feb in reply to Georgi Krustev Link to this post

    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

  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 25 Feb Link to this post

    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
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready