Custom Formatting of number

2 posts, 0 answers
  1. Lee
    Lee avatar
    31 posts
    Member since:
    Jun 2014

    Posted 17 May 2018 Link to this post

    I'm trying to create a custom number format for a bound column using MVC/Grid like you see in Excel where you have a positive;negative;zero formats  I keep getting errors this is what I've tried:

    .ClientTemplate("#= kendo.toString(RegularTimeHours, '##,##0.00;(##,##0.00);-' ) #")

    .ClientTemplate("#= kendo.toString(RegularTimeHours, '{0:##,##0.00;(##,##0.00);-}' ) #")

     

    Could I get some direction on how to do this?

    Thanks

    Lee

  2. Stefan
    Admin
    Stefan avatar
    2950 posts

    Posted 21 May 2018 Link to this post

    Hello, Lee,

    Thank you for the details.

    I can assume that it could be an escaping issue due to the multiple "#" characters.

    In this case, we can recommend using an external function to for the client template:

    columns.Bound(p => p.RegularTimeHours).Width(140).ClientTemplate("#=formatNumber(RegularTimeHours)#");


    function formatNumber(value) {
        return kendo.toString(value, '0:##,##0.00;(##,##0.00);')
    }

    I hope this is helpful.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top