hacsky007 2020-02-23 16:40 采纳率: 50%
浏览 279
已结题

Kendo.for.AspNet.Core 2019.1.115 Grid 绑定数据不成功?

我使用vs2017 结合Kendo.for.AspNet.Core插件实现列表页面,但是一直绑定数据不成功,提示:Failed to load resource: the server responded with a status of 400 (Bad Request)

List页面代码:

@using Kendo.Mvc.UI;

    <div>
        @(Html.Kendo().Grid<GridModel>()
                                    .Name("Grid")
                                    .Columns(columns =>
                                    {
                                        columns.Bound(p => p.name).Width(150);
                                        columns.Bound(p => p.yearly).Width(150);
                                        columns.Bound(p => p.wordtext).Width(150);
                                        columns.Bound(p => p.ModelId).Width(130);
                                        columns.Command(command => command.Destroy()).Width(160);
                                    })
                                    .ToolBar(toolbar =>
                                    {
                                        toolbar.Create();
                                    })
                                    .Editable(editable => editable.Mode(GridEditMode.InCell))
                                    .Pageable()
                                    .Navigatable()
                                    .Sortable()
                                    .Groupable()
                                    .Filterable()
                                    .Scrollable()
                                    .DataSource(dataSource => dataSource
                                        .Ajax()
                                        .Batch(true)
                                        .PageSize(20)
                                        .ServerOperation(false)
                                        .Read("List_Read", "KendoGrid")
                                    )
        )

    </div>

控制器:

public class KendoGridController : Controller
{
public ActionResult List()
{
     return View();
}
[HttpPost]
 public ActionResult List_Read([DataSourceRequest] DataSourceRequest request)
{
     IEnumerable<GridModel> Read = GetAll();
     return Json(Read.ToDataSourceResult(request));
}
public IList<GridModel> GetAll()
{
     var result = Enumerable.Range(0, 50).Select(i => new GridModel
     {
            name = "test",
            yearly = DateTime.Now.Year,
            wordtext = "测试",
            ModelId = i
      }).ToList();

      return result;
}
}

Model:

public class GridModel
{

        public string name { get; set; }
        public int yearly { get; set; }
        public string wordtext { get; set; }
        public  int ModelId { get; set; }
}

图片说明

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-02-23 20:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能