2
votes

I am using kendo grid . I have a column Category which i used for grouping . So i need to show category wise total in group footer template.

So I have used below code

.ClientGroupFooterTemplate(@"<span id=""spnGroupTotalPrice"" style=""float:right;"">#=sum#</span>");

This will work properly when page load. But i want to change the total price when editing Quantity column. So I tried below code

  .ClientGroupFooterTemplate(@"<span id=""spnGroupTotalPrice"" style=""float:right;"">#=calculate(Category)#</span>");

But It is not available column values in group footer template. I want to pass category name to calculate function.

Please provide a solution. Thanks in advance.

1

1 Answers

1
votes

I solved my issue.

calculate_sub_total()
{
    grid.tbody.find('> tr').each(function () {
      var tr = this;
      var cells = tr.cells;
      if ($(tr).hasClass('k-group-footer')) {              
         groupTotalPrice = (Math.round(groupTotalPrice * 100) / 100).toFixed(2);
         $(cells).find("#spnGroupTotalPrice").html(groupTotalPrice);
         groupTotalPrice = 0;// clearing after finishing a group
      }
      else if (!$(tr).hasClass('k-grouping-row')) {
         var rowItem = grid.dataItem(tr);
         groupTotalPrice = parseFloat(groupTotalPrice) +     parseFloat(rowItem.TotalPrice);
      }
   }); 
}

By calling above function in onChange event of grid.. Hope it would be useful. It is rare question in stack overflow.. :)