Home > other >  Kendo Grid set the aggregate based on selected value
Kendo Grid set the aggregate based on selected value

Time:11-11

By default my grid already had the total price (if none is selected). What I wanted if the row/checkbox is selected, the "Total Price" only calculate the sum based on selected row. Need help how can I achieve this.

Here is my Kendo Demo

CodePudding user response:

You can add a placeholder element in the footer and update the content based on the selection:

function onChange(arg) {
      var grid = $("#grid").data("kendoGrid");
      var data =[];
      grid.selectedKeyNames().forEach((itm)=>{
        data.push(grid.dataSource.get(itm));
      });
      var totalSelectedAmount = data.map(x=>x.UnitPrice).reduce((a, b) => a   b, 0);
      $("#total").html(totalSelectedAmount)
    }

Example

  • Related