MVC 5, Kendo 2017.2.504
I can't get a calculated column to format properly (to currency).
I've tried using a javascript function call in the ClientTemplate
but the js function is never called.
.ClientTemplate("#=formatCurrency(TotalAmount*Deductibility)#")
function formatCurrency(value) {
var result = kendo.toString(value, "c");
return result;
}
Also tried using kendo.toString
directly:
.ClientTemplate("#= kendo.toString(TotalAmount*Deductibility, 'C') #")
.ClientTemplate("#= kendo.toString(TotalAmount*Deductibility, 'c') #")
Here's the grid definition (only showing column needed). One thing to note,
the grid has expandable rows (defined in the DetailTemplate
), the expandable rows use an ajax datasource but the outer grid does not. I think that is part of the issue, I'm using a ClientTemplate
(in the outer grid) but the data source is not Ajax. Everything else about the grid is working as expected:
Html.Kendo().Grid(Model)
.Name("TaxClass")
.Columns(columns =>
{
...
columns.Template(c => c.TotalAmount * c.Deductibility).Title("Amount Deductible").ClientTemplate("#=formatCurrency(TotalAmount*Deductibility)#")
.HtmlAttributes(new {@class = "currency"}).Width(110);
})
.DetailTemplate(
...
)
.Filterable()
.DataSource(dataSource => dataSource.Server())
.Render();
}