Kendo Grid Aggregate not working

2 posts, 0 answers
  1. Raj
    Raj avatar
    2 posts
    Member since:
    Mar 2016

    Posted 09 Dec 2016 Link to this post

    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#" }               
                ]         
            });
  2. Stefan
    Admin
    Stefan avatar
    2205 posts

    Posted 13 Dec 2016 Link to this post

    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.
Back to Top