user1073794
user1073794

Reputation: 87

ASP.NET Kendo UI grid calculate columns

I have a grid and I want to calculate the column. Here is the code I have to calculate the total column

    @(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);


      })


  ))

I want to calculate the last column.

Upvotes: 1

Views: 2312

Answers (2)

Santosh
Santosh

Reputation: 2430

If you want to calculate at runtime, handle Grid Change event and use the solution here: Kendo Asp.net MVC Grid Batch Mode Calculated Column Display does not update

Upvotes: 0

Petur Subev
Petur Subev

Reputation: 20193

You can try with the following template :) :

#= UnitPrice*Tax #

Upvotes: 1

Related Questions