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

Remote Binding, What am I missing?

2 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cynthia
Top achievements
Rank 1
Cynthia asked on 05 Mar 2014, 04:19 AM
@(Html.Kendo().Grid<Zeus.Models.QuestionGroup>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.Id);
            columns.Bound(p => p.Name);
        })
        .HtmlAttributes(new { style = "margin:10px;height:230px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(20)
            .Read(read => read.Action("Answers2", "Survey"))
        )
)

Above is some MVC code.  I've tested this code using local binding and it works, but when I call it remotely and bind it, it doesn't.  However, it does trace into the following function:

       public ActionResult Answers2()
        {
/* SNIP */
 
            Models.Survey survey = modelSurvey.GetFull();
 
/* SNIP */
 
            return Json(survey.QuestionGroups);
        }

And I see the trace using Fiddler,  and I can debug it, but when the Json object is returned, nothing shows up in the grid.  There is data there, and Im getting no javascript errors.  Any idea what I'm missing?

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 Mar 2014, 09:20 AM
Hello,

The JSON you are returning is not in a format known to the grid. I recommend checking the ajax binding help topic which shows how to bind the Kendo UI to an action method.

Regards,
Atanas Korchev
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Cynthia
Top achievements
Rank 1
answered on 05 Mar 2014, 04:01 PM
Yes.  Adding:

            DataSourceResult result = survey.QuestionGroups.ToDataSourceResult(request);
            return Json(result);

To the code seems to work.  It would have been very helpful if in this example:
http://demos.telerik.com/kendo-ui/web/grid/remote-data.html

The Remote_DataController.cs file showed that this is required., however it maybe that it is implied.
Tags
Grid
Asked by
Cynthia
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Cynthia
Top achievements
Rank 1
Share this question
or