I have a generic partial view that I want to use for all of my Grids. The Model for the partial view it a Report object. The Report object has a DataTable property that contains the Grid's data source. The Report is also handling its own pages, page size, filtering, sorting, and grouping. The Ajax call is returning with the correct total number of records and I know that the Report.Query.PagedResults has the correct data. However, when the DataTable is passed to the extension "ToDataSourceResult()" the Data comes back without the data provided in the PagedResults. It's just an empty dictionary. This causes the grid to change pages but the data is missing, only the first page ever has data. Can you provide me with some guidance on what I might be missing?
_GridPartialView
Controller Ajax Action (the comments are other failed attempts to get it to work)
_GridPartialView
@model GridReport
@using System.Data;
@using MVCReportingConcept.Reports;
<
div
id
=
"report"
class
=
"chart-wrapper"
>
@(Html.Kendo().Grid(Model.QueryResults)
.Name(Model.Name)
.EnableCustomBinding(true)
.Columns(columns =>
{
foreach (DataColumn col in Model.QueryResults.Columns)
{
columns.Bound(col.ColumnName);
}
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Total(Model.Query.TotalRecordCount)
.Read(read => read.Action("ReadGrid", "Home", new { reportId = Model.ReportId }))
.PageSize(Model.PageSize)
)
)
</
div
>
public
ActionResult ReadGrid([DataSourceRequest] DataSourceRequest request,
int
reportId)
{
GridReport report = (GridReport)ReportBuilder.BuildReport(reportId);
report.Refresh(request.Page, request.PageSize);
DataSourceResult ds = report.Query.PagedResults.ToDataSourceResult(request);
//ds = report.QueryResults.ToEnumerable().ToQueryable().ToDataSourceResult(request);
//ds.Data = report.DataSourceResult.Data;
ds.Total = report.Query.TotalRecordCount;
return
Json(ds);
}