Search code examples
kendo-asp.net-mvc

Kendo mvc grid template format


My application is MVC5 C#; using Kendo MVC grid, need to format as currency an item.

 columns.Bound(p => p.IsFree).Template(@<text> @if (item.IsFree)
            {
                <span>Free</span>
            }
            else
            {
                <span>@item.Price </span>

            }</text>).Title("Cost");

Could not find any documentation how to format @item.Price as currency.


Solution

  • You can use ClientTemplate instead of Template with if else condition like below

    columns.Bound(c => c.IsFree).ClientTemplate("# if(IsFree) {#  <span>Free</span> #} else{# <span>#= kendo.toString(Price, 'C') #</span> #}#").Title("Cost")