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

Grid won't bind to data returned from its datasource's read() method

1 Answer 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 22 May 2014, 08:55 PM
Hi,

I have the following read method defined in the datasource of my Kendo grid.

.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.SomeID))
.Create(update => update.Action("EditingPopup_Create", "ControllerName"))
.Read(read => read.Action("EditingPopup_Read", "ControllerName").Data("additionalInfo"))
.Update(update => update.Action("EditingPopup_Update", "ControllerName"))
.Destroy(update => update.Action("EditingPopup_Destroy", "ControllerName"))

I make the following call to get data back from the EditingPopup_Read() method:

$("#grid").data("kendoGrid").dataSource.read();
$("#grid").data("kendoGrid").refresh();

The read() call hits the controller via a POST. The EditingPopup_Read() method prepares an array of models, and passes it back like this "return Json(models);"

I can see that JSON does in fact get passed back using Fiddler, however the Kendo grid either ignores it or refuses to display it, despite my call to refresh() the grid.  






1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 May 2014, 08:18 AM
Hello Dave,

Judging from the provided information it seems that the issue may be due to incorrectly formatted server response. As you may know the Grid widget expected the server response to be formatted in specific way (represented by DataSourceResult class) - data should be set as Data property and the total number of records should be in Total field. The easiest way to construct and populate instance of this class will be via the ToDataSourceResult extension method. More details on how to Ajax bind our Grid for ASP.NET MVC can be found in this help article. Also information on Ajax editing can be found here.

Regards,
Rosen
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
Dave
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or