This is a migrated thread and some comments may be shown as answers.

Custom Formatting of number

1 Answer 1163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 18 May 2018, 01:54 AM

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

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 May 2018, 06:09 AM
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.
Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or