Aggregates with multiple groupings

2 posts, 0 answers
  1. Timothy
    Timothy avatar
    1 posts
    Member since:
    Apr 2013

    Posted 23 Apr 2013 Link to this post

    I have an aggregate on the quantity column returning the sum. Is it possible for it to only return the total for one groupings instead of returning a total for each of my groupings? I would just like a total for the ShippedDate grouping.
            
    /// Code ///
    01.        @(Html.Kendo().Grid(Model)
    02.    .Name("Grid")
    03.    .HtmlAttributes(new { style = "width:80%" })
    04.    .Columns(columns =>
    05.    {
    06.        columns.Bound(p => p.CountyID);
    07.        columns.Bound(p => p.County);
    08.        columns.Bound(p => p.OrderNum);
    09.        columns.Bound(p => p.ShippedDate).Format("{0:MM/dd/yyyy}");
    10.        columns.Bound(p => p.InvCode);
    11.        columns.Bound(p => p.TagName);
    12.        columns.Bound(p => p.Quantity)
    13.            .ClientGroupFooterTemplate("Total: #=sum#");
    14.    })
    15.    .Groupable()
    16.    .Pageable()
    17.    .Sortable()
    18.    .Filterable()
    19.    .DataSource(dataSource => dataSource
    20.        .Ajax()
    21.        .Group(g => g.Add(p => p.CountyID))
    22.          .Group(g => g.Add(p => p.County))
    23.            .Group(g => g.Add(p => p.OrderNum))
    24.              .Group(g => g.Add(p => p.ShippedDate))
    25.         .Aggregates(aggregates =>
    26.            {
    27.                aggregates.Add(p => p.Quantity).Sum();
    28.            })
    29.        .Read(read => read.Action("CountyMonth_Read", "Report").Data("CountyMonthData"))
    30.        .PageSize(10)
    31. 
    32.    )
    33. 
    34.)
  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 25 Apr 2013 Link to this post

    Hello Timothy,

    This is not supported. The Grid will create grouping rows and will call the template for each group. It is possible to display only the total for the "ShippedDate" group by data parent field:

    columns.Bound(p => p.Quantity)
            .ClientGroupFooterTemplate("#if(data.parent().field == 'ShippedDate'){#Total: #=sum# #}#")
    but the rows for the other groups will still be shown. Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top