This is a migrated thread and some comments may be shown as answers.

Kendo Grid is not Ajax binding

3 Answers 281 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dewey
Top achievements
Rank 1
Dewey asked on 06 Aug 2013, 10:36 PM
My Kendo grid is not Ajax binding.  My code mimics what is in your examples exactly, so I can't see the problem.
The grid:
@(Html.Kendo().Grid<LedgerEntryViewModel>()
 .Name("grdItems2")
 .DataSource(datasource => datasource
 .Ajax()
 .Read(read => read.Action("GeneralLedgerEntries", "GL").Data("gridBindingData"))
 .PageSize(10)
 )
 .Columns(col =>
 {
col.Bound(c => c.AccountingEventName).Title("Accounting Event").HtmlAttributes(new {style = "white-space:nowrap;width:50%;"});
 })
 .Sortable()
 .Pageable()
 )

I can see in Fiddler that the controller code is returning the correct JSON to the page: 
public ActionResult GetEntries(string accountType, int? categoryID, int? accountID, int? year, int? month,
 [DataSourceRequest]DataSourceRequest request)
 {
var list = new List<LedgerEntryViewModel>();
 
list = _gridHelpers.GetAccountEntriesWithRunningTotal(accountType, accountID.Value);
 
DataSourceResult result = list.ToDataSourceResult(request);
var json = Json(list, JsonRequestBehavior.AllowGet);
 return json;
 }    

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 07 Aug 2013, 03:36 PM
I assume the problem is that the controller Json Action is never getting called?

Your grid is calling this controller action.
.Read(read => read.Action("GeneralLedgerEntries", "GL").Data("gridBindingData"))
But yet your controller action is actually called: GetEntries
public ActionResult GetEntries
Change one of the other to match.

I'm only learning myself so hopefully this helps.

Thanks,
0
Dewey
Top achievements
Rank 1
answered on 07 Aug 2013, 06:06 PM
Actually the method name is "GeneralLedgerEntries" in both the controller and the "Read" method call.  I changed it in the controller to obscure our app (but not very well).  So that is not the issue.  But thanks for your post anyway.
0
Daniel
Telerik team
answered on 08 Aug 2013, 02:31 PM
Hello,

The code looks correct. Could you check what is the response from the server? It should indicate what is causing the problem. Also, please check if there are any JavaScript errors.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Dewey
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Dewey
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or