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

Aggregates with multiple groupings

1 Answer 956 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 23 Apr 2013, 08:28 PM
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.)

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Apr 2013, 01:25 PM
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!
Tags
Grid
Asked by
Timothy
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or