-1

using mvc kendo grid to represent the dat

I have decimal values likes

Actual O/P

61.05      
16.00
15.92

Expected O/P This is What i am looking for

61.05      
16
15.92

I used to display the value like this

Format("{0:n2}")

How can I achieve expected o/p, with the help of kendo format

Cœur
  • 37,241
  • 25
  • 195
  • 267
Prasad Raja
  • 685
  • 1
  • 9
  • 37
  • 1
    Is the value `type` being passed in a number or a string? If it is a string then the formatting won't do anything as kendo will treat the value as a string and not a number. I have fallen foul to this before. As what you have put should work perfectly fine. – David Shorthose May 08 '17 at 12:06
  • Try using `.ToString("G29")` on your decimal value. This will truncate trailing zeroes on your value. However, if it's possible in your situation to have a value like `0.0001` then you could run into some problems. Check out [this question](http://stackoverflow.com/questions/4525854/remove-trailing-zeros/4525983#4525983) for more info. – ShawnOrr May 09 '17 at 17:44
  • @DavidShorthose type is decimal value. – Prasad Raja May 10 '17 at 04:55

3 Answers3

0

Strange, that should actually work.

You can try the following formatting string as an alternative solution: {0:0.00}.

Teodor Kurtev
  • 1,049
  • 1
  • 13
  • 24
0

Format("{0:n2}") will force all input numbers to 2 decimal places. If you want to apply decimal places based on the value, use Format("0:0.##}") (where the number of decimal places (#) is the maximum number of decimal places you will have).

Sandman
  • 2,247
  • 1
  • 13
  • 26
0

If you don't need the column to be numbers (for example for sorting, filtering or summing in the grid), then pass string values to the column and do the unusual formatting requirement in the controller.

Graham Laight
  • 4,700
  • 3
  • 29
  • 28