I need to create a calculated column in Kendo Grid within ASP.Net. Something like this: http://jsbin.com/ojomul/89/edit where Full name is a calculated column. I tried doing this using using kendo server controls but unable to make it work. Here is my code:What I need is have the Total column calculated by the javascript function and update the UI automatically. Thanks
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductId).Groupable(false);
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitPrice);
columns.Bound(p => p.Quantity);
columns.Bound(p => p.Tax);
columns.Bound(p => p.Total).ClientTemplate("#= calculate() #");
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Editable(e=>e.Mode(GridEditMode.InCell))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Products_Read", "Product"))
.PageSize(20)
.Model(model =>
{
model.Id(p => p.ProductId);
model.Field(p => p.ProductName);
model.Field(p => p.UnitPrice);
model.Field(p => p.Quantity);
model.Field(p => p.Tax);
})
))
<
script
type
=
"text/javascript"
>
function calculate(e) {
var result = p.UnitPrice * p.Quantity * p.Tax;
return result;
}
</
script
>