Reputation: 759
I have a Kendo Grid with a list of products and their respective amounts. Each product may have a different decimal precision, but I don't know how to reflect this in the Grid. As far as I can figure out, it is only possible to set the format for the entire column.
Currently, with format as {0:n2}
, the Grid will display as:
PRODUCT AMOUNT PRECISION
Product A 10,00 0
Product B 10,00 2
Product C 10,00 3
Product D 10,00 1
While the desired result would look like:
PRODUCT AMOUNT PRECISION
Product A 10 0
Product B 10,00 2
Product C 10,000 3
Product D 10,0 1
Is it even possible to specify a different format for each row in Kendo Grid?
Upvotes: 0
Views: 197
Reputation: 759
I've managed to solve it by defining a template for the column, as gitsitgo suggested in the comments.
On the bound column, using C# and Razor, I specified the following template:
@<text>@item.Amount.ToString("F" + item.Precision, formatProvider)</text>
Where formatProvider
is a reference to an IFormatProvider, holding the current CultureInfo.
Upvotes: 1