Kendo showing negative zero when using conditional formatting

5 posts, 0 answers
  1. Jacob
    Jacob avatar
    21 posts
    Member since:
    Dec 2011

    Posted 11 Oct Link to this post

    We are using kendo’s support for conditional formatting to build custom masks. For example:

    kendo.toString(value, ‘\\$0;-\\$0’) // e. g. -$100 or $100

    The problem is that kendo picks which side of the conditional formatting to use BEFORE rounding is applied. Thus we can end up with a display of negative zero:

    kendo.toString(-.01, ‘\\$0;-\\$0’) // -$0

    Note that this is similar to this issue: http://www.telerik.com/forums/issue-rounding-to-zero---getting-negative-zero, however that issue is for the built-in n2 format whereas our issue is for conditional formats.

    Note that in C#/.NET, the behavior of conditional formats matches what we want:

    Console.WriteLine((-.01).ToString("$0;-$0")); // $0

    For reference, the reason we are building masks like this is because we have user-defined “front” and “back” symbols which should go between the negative/positive sign (or parens if we are using parens for negation) and the number itself. We thus want -$100 or ($100) instead of $-100 or $(100).

    It would be great if kendo’s behavior matched .NET in this regard since it seems to be so similar otherwise and in general the .NET behavior seems preferable in most cases.

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

    http://stackoverflow.com/questions/39977630/kendo-conditional-formatting-results-in-negative-zero

  2. Stefan
    Admin
    Stefan avatar
    268 posts

    Posted 12 Oct Link to this post

    Hello Jacob,

    After consulting with our developers' team, I can confirm that the described behaviour is expected.

    In this scenario, I can suggest using the "c0" format to achieve similar result:

    http://docs.telerik.com/kendo-ui/framework/globalization/numberformatting#types-of-number-formats

    Still, as the described result is expected in many scenarios, I can suggest submitting a feature request in our UserVoice portal and based on its popularity we may implement it in a future release:

    http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback

    Let me know if you need additional information on this matter.

    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 12 Oct in reply to Stefan Link to this post

    Hi Stefan,

    We can't actually use the "c0" format for our use-case. In the example, the '$' is just a placeholder. For us this is a user-defined value and could be an arbitrary currency symbol, units, etc.

    We also rely on conditional formatting to allow for customization of how negative numbers display (e. g. "($10)" vs. "-$10").

    As you say, the current behavior is not what devs or users generally want/expect, so I do consider this a bug rather than an enhancement request.

    Nevertheless, I'm happy to file a request for this on UserVoice as well.

  5. Mike
    Mike avatar
    6 posts
    Member since:
    Oct 2016

    Posted 12 Oct in reply to Mike Link to this post

    I've created a UserVoice issue for this as well: http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/suggestions/16619986-fix-kendo-number-formatting-to-avoid-displaying-ne
  6. Stefan
    Admin
    Stefan avatar
    268 posts

    Posted 14 Oct Link to this post

    Hello Mike,

    Thank you for the feedback and the feature request.

    Your notes for the current behaviour of the widget were forwarded to our developers' team.

    Let me know if you need additional assistance on this matter.

    Regards,
    Stefan
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top
Kendo UI is VS 2017 Ready