Remote Binding, What am I missing?

3 posts, 0 answers
  1. Cynthia
    Cynthia avatar
    13 posts
    Member since:
    Apr 2012

    Posted 04 Mar 2014 Link to this post

    @(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. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 05 Mar 2014 Link to this post

    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!

  3. Cynthia
    Cynthia avatar
    13 posts
    Member since:
    Apr 2012

    Posted 05 Mar 2014 Link to this post

    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.
Back to Top