首页 > 解决方案 > 剑道网格不显示任何数据

问题描述

我的项目是 asp.net core 3.1,我尝试将剑道网格与读取操作绑定。我的剑道网格是空的,没有显示任何数据

这是我的行动:

public JsonResult Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = _context.Products.OrderByDescending(c => c.Id);
            DataSourceResult result = data.ToDataSourceResult(request,
                model => new Product
                {
                    Id=model.Id,
                    Title=model.Title
                });
            //return Json(result, JsonRequestBehavior.AllowGet);
            return Json(result);
        }

这是我的剑道网格:

@model IEnumerable<DomainModel.Product>
@addTagHelper *, Kendo.Mvc
@using Kendo.Mvc.UI

@(Html.Kendo().Grid<DomainModel.Product>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.Id);
            columns.Bound(c => c.Title);
        })
        .HtmlAttributes(new { style = "height: 550px;" })
        .Scrollable()
        .Groupable()
        .Sortable()
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Read", "Products"))
            .PageSize(15)
        )
    )

谢谢

标签: asp.net-mvcasp.net-corekendo-uikendo-gridkendo-asp.net-mvc

解决方案


推荐阅读