Hi,
We have a property EnableHeaderContextAggregateMenu in Radgrid. By enabling this, we can aggregate any column in the Radgrid and show the result value in the corresponding column footer at runtime by the end user.
Do we have similar property in Kendo UI Grid? We need to implement this in Kendo UI Grid which has dynamic column data binding. We had attached a sample code here. Can you please implement the same in the code and revert?
Thanks & Regards,
Shivakumar. K
Hi,
Truly speaking, this could be a really useful feature for the end-users, if we allow them to do the necessary aggregration on their own at run-time instead of enforcing to do it in fixed manner.
You can proceed on this.
Thanks & Regards,
Shivakumar. K
Hi,
Do you have any idea on when the dynamic aggregation feature will be ready for use?
Thanks & Regards,
Shivakumar. K
.Aggregates(aggregates =>
{
foreach
(System.Data.DataColumn column
in
Model.Columns)
{
if
(column.DataType ==
typeof
(
int
))
{
aggregates.Add(column.ColumnName,
typeof
(
int
)).Sum();
}
if
(column.DataType ==
typeof
(
string
))
{
aggregates.Add(column.ColumnName,
typeof
(
int
)).Count();
}
}
})
.Columns(columns =>
{
foreach
(System.Data.DataColumn column
in
Model.Columns)
{
var c = columns.Bound(column.ColumnName);
if
(column.DataType ==
typeof
(
string
)) {
c.ClientFooterTemplate(
"count: #=count #"
);
}
if
(column.DataType ==
typeof
(
int
)) {
c.ClientFooterTemplate(
"sum: #=sum #"
);
}
}
})
public
IActionResult Read([DataSourceRequest] DataSourceRequest request)
{
var res = GetDataTable(500).AsEnumerable().Select(x=>
new
{
Field1 = x.Field<
string
>(
"Field1"
),
Field2 = x.Field<
int
>(
"Field2"
)
});
return
Json(res.ToDataSourceResult(request));
}