如何为Kendo UI网格使用不同的数据源?

我对Kendo不太熟悉,并且看过一些教程,但即使严格按照以下步骤我也不会得到相同的结果。我使用缓存的数据制作了一个页面,并将其作为数据源以不同的方式传递给网格。

在此代码中,根本没有调用read方法。我不知道为什么。

@(Html.Kendo().Grid<TestCategory>().Name("TCategory1").Columns(c =>
    {
    c.Bound(p => p.Name);
    c.Bound(p => p.Id);
    })
        .DataSource(d => d.Ajax().Read(r => r.action("Read","Category").Type(HttpVerbs.Get))
        .PageSize(3))
        .Pageable()
        .Sortable()
        .Filterable()
    )

在第二个网格中,我能够显示数据,但无法编辑

@(Html.Kendo().Grid(Model).Name("TCategory").Columns(c =>
    {
    c.Bound(p => p.Name);
    c.Bound(p => p.Id);
        c.Command(com => { com.Edit(); com.Destroy(); });
    })
        .DataSource(d => d.Ajax().ServerOperation(false).PageSize(3)
        .Update(u => u.action("Edit","Category"))
        .Create(c => c.action("Create","Category"))
        .Destroy(c => c.action("Delete","Category"))
        .Model(m => { m.Id(p => p.Id); })
        )
        .Pageable().Editable(e => e.Mode(GridEditMode.InCell)).Sortable().Filterable().ToolBar(t => t.Create()) )

读取方法:

[HttpPost]
    public JsonResult Read([DataSourceRequest]DataSourceRequest request)
    {
        IQueryable<TestCategory> cat = context.Collection();


        return Json(cat.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
    }
zhangzhang00 回答:如何为Kendo UI网格使用不同的数据源?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3147516.html

大家都在问