Kendo format string puts literal '?' in the wrong place

5 posts, 0 answers
  1. Mike
    Mike avatar
    6 posts
    Member since:
    Oct 2016

    Posted 12 Oct Link to this post

    We allow users to specify custom symbols as part of the number formats they see in our software. We are using Kendo's formatting capability to incorporate these symbols as part of our format strings. For example, we might have a format string like:

    var format = "\\$0.00\\/\\h\\r;(\\$0.00\\/\\h\\r)";

    kendo.toString(-1.7, format); // ($1.70/hr)

    Note the use of backslashes to escape literal characters in the format string. This seems to work well, except when the ? character is used. Here's an example:

    var format = "\\?\\x0";

    kendo.toString(100, format); // returns "x?100", but I would expect "?x100"

    This definitely seems like a bug. I can't find any documentation (http://docs.telerik.com/kendo-ui/framework/globalization/numberformatting) explaining why the '?' character should receive special treatment at all, let alone when escaped.

    I've also posted this as a StackOverflow question:

    http://stackoverflow.com/questions/39977914/kendo-format-string-puts-literal-in-the-wrong-place

     

  2. Stefan
    Admin
    Stefan avatar
    268 posts

    Posted 14 Oct Link to this post

    Hello Mike,

    The ? symbol does not need to be escaped, that is why this result is different from the expected one.

    The following code snippet can be used to format the number in the desired way:

    var format = "?x0";
    console.log(kendo.toString(100, format));

    In our documentation we only listed the symbols that specifically need to be escaped:

    http://docs.telerik.com/kendo-ui/framework/globalization/numberformatting#custom

    If there is a symbol that needs to be escaped and it is not in the list we will be happy to add this information in the documentation.

    Regards,
    Stefan
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. Mike
    Mike avatar
    6 posts
    Member since:
    Oct 2016

    Posted 14 Oct in reply to Stefan Link to this post

    Hi Stefan,

    It's interesting that the bug sometimes disappears when the escaping is gone. HOWEVER, this does not solve the problem in general. Here's another example:

    var format = "?\\$0";
    console.log(kendo.toString(100, format)); // "$?100"

    In this case, the '?' is not escaped. The '$' DOES need to be escaped per the documentation because it will be translated to the currency symbol for the current culture. Note that escaping '?' does not fix the issue:

    var format = "\\?\\$0";
    console.log(kendo.toString(100, format)); // "$?100"

    While it isn't specifically documented that all characters support escaping, the fact that most already do is actually necessary to construct masks with other special characters like '0', ',', and '.'. Universal escaping is also critical for being able to share formats between kendo and .NET.

  5. Stefan
    Admin
    Stefan avatar
    268 posts

    Posted 18 Oct Link to this post

    Hello Mike,

    After testing the newly provided scenario, I can confirm that indeed the result is unexpected.

    I created an issue in our GitHub repository and forwarded it to our developers for fixing. You can track its progress at:

    https://github.com/telerik/kendo-ui-core/issues/2326

    Additionally, I updated your Telerik points from bringing this to our attention.

    Regards,
    Stefan
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  6. Mike
    Mike avatar
    6 posts
    Member since:
    Oct 2016

    Posted 18 Oct in reply to Stefan Link to this post

    Thanks Stefan I appreciate it!
Back to Top
Kendo UI is VS 2017 Ready