This is a migrated thread and some comments may be shown as answers.
Grid Paging CustomBinding and Empty Jason Result
1 Answer 29 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Moises
Top achievements
Rank 1
Moises asked on 20 Mar 2012, 02:54 PM
Hello,

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

1 Answer, 1 is accepted

Sort by
0
Moises
Top achievements
Rank 1
answered on 20 Mar 2012, 03:47 PM
Closure:

My GridAction attribute was missing the EnableCustomBinding property set to true.

For my fellow developers, make sure you also set in on your grid.
Tags
Grid
Asked by
Moises
Top achievements
Rank 1
Answers by
Moises
Top achievements
Rank 1
Share this question
or