5 Answers, 1 is accepted
0
Hello Stas,
The GroupHeaderTemplate contains local variable "item" which contains all available aggregates for current column. Please check the example below:
Regards,
Vladimir Iliev
Telerik
The GroupHeaderTemplate contains local variable "item" which contains all available aggregates for current column. Please check the example below:
columns.Bound(p => p.UnitsInStock)
.GroupHeaderTemplate(@<text>
@item.Title: @item.Key
(Count: @item.Count) (UnitsOnOrder Average: @item.Average)
</text>);})
.DataSource(dataSource => dataSource
.Server()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.UnitsInStock).Min().Max().Count();
aggregates.Add(p => p.UnitsOnOrder).Average();
Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

tarnegur
Top achievements
Rank 1
answered on 24 Jun 2015, 09:07 AM
Hello Vladimir.
Thank you for your answer. I know this, but I need to access ALL columns aggregates.
How can I access them in one group header?
.Aggregates(groupAggregates =>
{
groupAggregates.Add(x => x.Amount).Sum();
groupAggregates.Add(x => x.Net).Sum();
groupAggregates.Add(x => x.Gros).Sum();
groupAggregates.Add(x => x.Total).Sum();
})
@item.Sum will be only the aggregate of one of them.
0
Hello Stas,
Please note that you can't access the other fields duplicated aggregates (in server binding mode) as they are overridden by the current field aggregate. If you need to access all of the available aggregates then you should switch to ajax-binding mode.
Regards,
Vladimir Iliev
Telerik
Please note that you can't access the other fields duplicated aggregates (in server binding mode) as they are overridden by the current field aggregate. If you need to access all of the available aggregates then you should switch to ajax-binding mode.
Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

tarnegur
Top achievements
Rank 1
answered on 24 Jun 2015, 06:35 PM
Do you have an example, how to make it in an ajax bound grid?
0
Hello Stas,
There is no way to access all aggregate values from all column directly from inside a specific column's group header template, however, you can use script expressions inside the template to get the Grid object, then the Grid dataSource and obtain all aggregate values by using the DataSource API.
Here is a simplified example, based on the Aggregates demo. The result is shown on the attached screenshot.
http://demos.telerik.com/aspnet-mvc/grid/aggregates
http://docs.telerik.com/kendo-ui/framework/templates/overview
http://docs.kendoui.com/api/framework/datasource#methods-aggregates
Regards,
Dimo
Telerik
There is no way to access all aggregate values from all column directly from inside a specific column's group header template, however, you can use script expressions inside the template to get the Grid object, then the Grid dataSource and obtain all aggregate values by using the DataSource API.
Here is a simplified example, based on the Aggregates demo. The result is shown on the attached screenshot.
http://demos.telerik.com/aspnet-mvc/grid/aggregates
http://docs.telerik.com/kendo-ui/framework/templates/overview
http://docs.kendoui.com/api/framework/datasource#methods-aggregates
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name(
"Grid"
)
.Columns(columns =>
{
columns.Bound(p => p.UnitsInStock)
.ClientGroupHeaderTemplate(
"Units In Stock: #= value # (Count: #= count#) #=
kendo.stringify(grid.dataSource.aggregates())
#"
)
.ClientFooterTemplate(
"<div>Min: #= min #</div><div>Max: #= max #</div>"
);
})
)
<script>
var grid;
$(function () {
grid = $(
"#Grid"
).data(
"kendoGrid"
);
});
</script>
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!