kendo Grid不显示数据

时间:2017-12-16 20:00:56

标签: asp.net-mvc kendo-grid asp.net-core-mvc telerik-grid

我使用Kendo Grid在mvc核心中显示我的数据,如 Razor View

@(Html.Kendo().Grid<Dates.Model.DatesIoDetails>()
                .Name("DIoDetails")
                .Columns(columns =>
                {
                    columns.Bound(c => c.BoxNumber).Width(140);
                    columns.Bound(c => c.Weight).Width(100);
                    columns.Bound(c => c.Description);
                    columns.Bound(c => c.City.Name).Width(110);
                    columns.Bound(c => c.DatesType.Name).Width(110);
                    columns.Bound(c => c.DatesZone.Name).Width(110);
                    columns.Bound(c => c.Hall.Name).Width(110);
                })

                .HtmlAttributes(new { style = "height: 380px;" })
                .Scrollable()
                .Groupable()
                .Sortable()
                .Pageable(pageable => pageable
                .Refresh(true)
                .PageSizes(true)
                .ButtonCount(5))
                .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("GetDIoDetails", "DatesIOs", new { @area = "Software" }))
                ))

所有这些代码都在PartialView中调用为

@Html.PartialView("MyPartialView")

并且在控制中我有这个

  public IActionResult GetDIoDetails([DataSourceRequest] DataSourceRequest request)
    {
        var dio = _datesIoDetailsRepository.GetAll();
        return Json(dio.ToDataSourceResult(request));
    }

在_Layout我有这个

 <environment names="Development">

    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/jquery-ajax-unobtrusive/jquery.unobtrusive-ajax.js"></script>

    <script src="~/kendo-ui/js/kendo.all.min.js"></script>
    <script src="~/kendo-ui/js/kendo.aspnetmvc.min.js"></script>

</environment>

我也添加服务

        services.AddMvc();

        services.AddKendo();
        services.AddMvc().AddJsonOptions(options =>
        {
            options.SerializerSettings.ContractResolver = new DefaultContractResolver();
        });

我不知道为什么网格没有显示数据只显示没有数据的列标题 我在Controller中的Code中设置preakpoint,当我观看时它返回数据作为json,但是在Kendo Grid中没有显示数据! 的 更新 问我关于我的存储库,这是存储库中的代码

 public IEnumerable<DatesIoDetails> GetAll() => _db.DatesIodetails
             .Include(d => d.City)
            .Include(d => d.DatesIO)
            .Include(d => d.DatesType)
            .Include(d => d.DatesZone)
            .Include(d => d.Hall)
            .Include(d => d.OutType)
            .Include(d => d.PackingType)
            .Include(d => d.Province)
            .Include(d => d.Shelf)
            .Include(d => d.Unit);

0 个答案:

没有答案