I am trying out fairly basic databinding with hard coded data using Kendo Grid using MVC - ASP.NET Core. The Grid renders fine and the .read method is called. It returns JSON however, the data does not display in the grid. I verified no errors related to aspnet-mvc.js script. The required scripts are listed only once and in the correct order. Help appreciated. I tried using JsonResult. No luck.
@using Kendo.Mvc.UI @model IEnumerable<GridPortal.Web.Models.Company> <script src="~/lib/kendo/2020.1.406/js/kendo.all.min.js"></script> <script src="~/lib/kendo/2020.1.406/js/kendo.web.min.js"></script> <script src="~/lib/kendo/2020.1.406/js/kendo.aspnetmvc.min.js"></script> <div style="width:100%;height:60%"> @(Html.Kendo().Grid<GridPortal.Web.Models.Company>() .Name("BindGridUsingRead") .Columns(columns => { columns.Bound(p => p.Id).Width(15).Title("ID").Filterable(false); columns.Bound(p => p.Name).Title("Name").Width(30).Filterable(false); columns.Bound(p => p.CompanyId).Title("CompanyID").Width(15).Filterable(false); }) .Scrollable() .Pageable() .Filterable(ftp => ftp.Mode(GridFilterMode.Row)) .Resizable(resize => resize.Columns(true)) .HtmlAttributes(new { style = "height: 100%" }) .Selectable() .DataSource(dataSource => dataSource .Ajax() .Model(model => model.Id(p => p.Id)) .ServerOperation(false) .Read(read => read.Action("BindGrid", "Home"))) ) </div>public ActionResult BindGrid([DataSourceRequest] DataSourceRequest request){ var company = new List<Company>(); company.Add(new Company { CompanyId = 102, Id = 1, Name = "John Smith" }); DataSourceResult result = company.ToDataSourceResult(request);return Json(result); }
public void ConfigureServices(IServiceCollection services){ services.AddControllersWithViews(); services.AddKendo(); services.AddMvc().AddNewtonsoftJson(o => {o.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }).SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0); }