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

Kendo Grid Aggregate not working

1 Answer 1543 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 09 Dec 2016, 04:46 PM

I am trying to display the Sum of the Amount per ReceivedOn on the group footer.

Please help me to find what is wrong in here...

var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: THIS_APP_PATH + "Reports/Monthly/DepositList",
                    dataType: "json"
                }
            },
            schema: {
                parse: function (response) {
                    var amounts = [];
 
                    $.each(response.Amounts, function (i, amount) {
                        var amount = {
                            Id: amount.Id,
                            Amount: amount.Amount,
                            ReceivedOn: amount.Check != null ? amount.ReceivedOn : null,
                            Originator: amount.Check != null ? amount.Check.Originator : null,
                            CheckNumber: amount.Check != null ? amount.Check.Number : null,
                            CheckDate: amount.Check != null ? amount.Check.Date : null,
                            Comments: amount.Comments
                        };
 
                        amounts.push(amount);
                    });
 
                    return amounts;
                },
                model: {
                    id: "Id",
                    fields: {
                        Id: { type: "number" },
                        ReceivedOn: { type: "date" },
                        Originator: { type: "string" },
                        CheckNumber: { type: "string" },
                        CheckDate: { type: "date" },
                        Amount: { type: "number" },
                        Comments: { type: "string" }
                    }
                },
                group: [{
                    field: "ReceivedOn"//, aggregates: [{ field: "Amount", aggregates: "sum" }]
                }],
                aggregate: [{ field: "Amount", aggregate: "sum" }]
            }
        });
 
        $("#grid").kendoGrid({
            dataSource: dataSource,
            pageable: false,
            groupable: false,
            columns: [               
                { field: "ReceivedOn", title: "Received On", format: "{0:MM/dd/yyyy}"},
                { field: "Originator", title: "Originator", width: 200, groupFooterTemplate: "Total: #=sum#" },
                { field: "CheckNumber", title: "Check #", groupFooterTemplate: "Total: #=sum#" },
                { field: "CheckDate", title: "Check Date", format: "{0:MM/dd/yyyy}" },
                { field: "Amount", format:"{0:c}"},
                { field: "Comments", title: "Comments", width: 250, groupFooterTemplate: "Total: #=sum#" },
                { field: "Amount", groupFooterTemplate: "Total: #=sum#" }               
            ]         
        });

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Dec 2016, 08:42 AM
Hello Raj,

If I understand correctly the desired result is to group by the ReceivedOn column and to display a groupFooterTemplate under the Amount column showing the sum of all amounts.

If this is correct the group and the aggregates are correctly set, but I noticed the groupFooterTemplate is also set for columns which aggregates are not set.

Please check the example if the desired result is to display aggregates for only one column:

http://dojo.telerik.com/UyagO

Also, please check our example if more than one column will have aggregates:

http://demos.telerik.com/kendo-ui/grid/aggregates

If my assumption is not correct please provide more information about the scenario and I will gladly assist.

Regards,
Stefan
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Raj
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or