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

Grid not populating from Datasource

1 Answer 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 19 Jun 2013, 08:26 PM
Why is my grid still empty even though the datasource response is getting populated?

Controller method:
[HttpGet]
  public ActionResult Search([DataSourceRequest] DataSourceRequest request)
  {
      DataSourceResult result = new DataSourceResult();
 
      var data = new[] {
          new { PartID=1, PartNumber="ABC123", Description="Part One" },
          new { PartID=2, PartNumber="XYZ879", Description="Part Two" },
          new { PartID=3, PartNumber="ZZZ999", Description="Part Three" },
      };   
 
      result = data.ToDataSourceResult(request);
      return Json(result, JsonRequestBehavior.AllowGet);
  }
Client:
var dataSource = new kendo.data.DataSource({
      transport: {
          read: {
              serverPaging: false,
              serverSorting: false,
              url: "@Url.Action("Search", "PartMaster")",
              dataType: "json",
              type: "GET"
          },
          schema: {
              data: "Data",
              model: {
                  fields: {
                      PartID: { type: "number" },
                      PartNumber: { type: "string" },
                      Description: { type: "string" }
                  }
              }
          }
      },
      requestEnd: function (e) {
          var response = e.response;
          var type = e.type;
          console.log(type);
          console.log(response.length);
      }
  });
 
  function dataSourceError(e) {
      console.log(e.status);
  }
   
  dataSource.bind("error", dataSourceError);
   
  $("#resultsGrid").kendoGrid({
      dataSource:dataSource,
      height: 600,
      scrollable: true,
      sortable: true,
      columns: [{ field: "PartID" }, { field: "PartNumber" }, { field: "Description" }],
      dataBound: function (e) {
          console.log(e);
      }
  });

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 20 Jun 2013, 07:18 AM
Hello,

 The ToDataSourceResult extension method is supported only when the MVC wrappers are used. You can find more info here: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/ajax-binding

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