This is a migrated thread and some comments may be shown as answers.

Footer Total with Pagination in Kendo Grid

1 Answer 844 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Monalisa
Top achievements
Rank 1
Veteran
Monalisa asked on 06 Oct 2020, 04:57 PM

I have a requirement to show total of column value on footer of the grid. I have created method to calculate total for each column and calling the same method on grid data bound.

I have applied paging in kendo grid, so while changing page the total value also getting changed, means the total in footer showing only for particular page records.

But i have requirement to show total value of column for all records in footer even if paging is there.

function CalculateTotal() {

        var currentDataItem = $("#gridLiabilitySchedules").data("kendoGrid").dataItem($(this).closest("tr"));
        for (var i = 0; i < grid.dataSource._data.length; i++) {
            totalOriginalBudget = totalOriginalBudget + grid.dataSource._data[i]["OriginalBudget"];
            totalAwardValue = totalAwardValue + grid.dataSource._data[i]["AwardValue"];
            totalBuyingGainLoss = totalBuyingGainLoss + grid.dataSource._data[i]["BuyingGainLoss"];
            totalCurrentBudget = totalCurrentBudget + grid.dataSource._data[i]["CurrentBudget"];}}

 

    function LiabilitySchedulesGrid_DataBound(e) {
        $('#hdnLiabilitySchedulesremovedata').val(false);
        CalculateTotal();
        $('#hdnLiabilitySchedulesGridValCount').val($('#gridLiabilitySchedules').data('kendoGrid').dataSource.total() == 0 ? "" : "1");
    }

 

Please provide me a solution to show total of column value for all records in footer of grid with paging.

 

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 08 Oct 2020, 03:52 PM

Hi, Monalisa,

The UI for ASP.NET Grid uses server operations by default and if the calculation are done on the client, it is expected that they only use the data on the current page. This is because server paged grids (default ajax grid) only have a pageSize worth of records.

The custom calculation should work as expected if you set ServerOperation(false)

For server operation, you can provide the aggregates in the data source definition and then transform them in the template as needed:

https://www.telerik.com/forums/doing-math-on-aggregates#BmRJcQ0waUm6EiXu6nFIRA

Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Monalisa
Top achievements
Rank 1
Veteran
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or