Specs
Kendo: 2012.3.1114
Net: 4.5
MVC: 4.0
Problem
I am binding my grid using a DataTable as the Model and need to have aggregate values. I have to use the datatable as I have a lot of data that is being sent over from the web service. If wrapped as XML it was over 55 MB for 21 columns and 14,400 rows so we converted the SQL DataTable to CSV and then sent the string over. That resulted in a file around 5MB.
The data that I a getting has no model as there can easily be 200+ columns depending on the query so making a data model is sadly out of the question.
If I use the snippet below as my base (taken from the Kendo UI Code Library) there seems to be no way to set up the aggregate functions
@(Html.Kendo().Grid(Model)
.Name(
"Grid"
)
.Columns(columns => {
foreach
(System.Data.DataColumn column
in
Model.Columns)
{
columns.Bound(column.DataType, column.ColumnName);
}
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action(
"Read"
,
"Home"
))
)
)
Back in the days of the Telerik MVC controls I could set up the aggregate function you could setup the aggregate while adding the bound column but in the Kendo UI wrapper that has been moved down to be inside of the DataSource.
Telerik Grid:
columns.Bound(
"ColumnName"
).Aggregate(aggregates => aggregates.Count().Min().Max())
If I try and set up the agregate down in the DataSource I get a lovely exception "'count' is undefined" which is a bit vague.
if
(column.ColumnName ==
"ProductID"
)
{
columns
.Bound(column.DataType, column.ColumnName)
.ClientFooterTemplate(
"Count: #=count#"
);
}
...
.Aggregates(aggregates =>
{
aggregates.Add(a =>
"ProductID"
).Count();
})
Is there any way to get around the aggregate problem?