I am trying to setup paging with CustomBinding as I have an N-Tier architecture and the Grid mechanism can't talk straight to my data source.
When the grid is first loaded, the data looks correct in terms of the number of pages and the records per page. Things go awry as soon as I start paging. Any subsequent page shows no data.
My action method (decorated with the [GridAction] attribute is correctly called, the GridCommand has the right properties set, my middle tier returns the correct chunck of data. I populate the GridModel object as well. Upon close inspection, I noticed that the Json that is returned is empty. What am I missing in order to make Json serialization work correctly?
Here is my setup:
View:
@{Html.Telerik().Grid<
ApplicationModel>(Model.Applications)
.Name(
"ApplicationsGrid")
.Columns(columns =>
{
columns.Bound(o => o.OrganizationName).Width(40);
columns.Bound(o => o.ReferenceNumber).Width(25);
columns.Bound(o => o.StatusDate).Width(25);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select(
"GridRequest", "Home"))
.Pageable(paging => paging.Total((
int)ViewBag.TotalRecords))
.EnableCustomBinding(
true)
.Render();
}
Controller:
[
GridAction]
public ActionResult GridRequest(GridCommand gridCommand)
{
HomepageViewModel m = userService.GetHomepageViewModel(CurrentUser.UserId, gridCommand.Page);
ViewBag.TotalRecords = m.TotalApplicationsCount;
return View(new GridModel<ApplicationModel>
{
Data = m.Applications,
Total = m.TotalApplicationsCount
});
}
---
As I investigate further, I checked that my object graph did not produce any errors that might be hindering the Json process. I fed the entire GridModel to an instance of the JavaScriptSerializer and got Json.
dummy = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(gridModel);
This means that somewhere between the return and the javascript in the page something is not working right.
Any help will be greatly appreciated