gpt4 book ai didi

c# - 如何绑定(bind)剑道网格

转载 作者:太空宇宙 更新时间:2023-11-03 13:36:29 25 4
gpt4 key购买 nike

我已经创建了 asp.net MVC 4 应用程序,我在其中使用 Entity Framework ,“数据”类是模型。

AdventureWorksTrainingEntities _dbContext = new AdventureWorksTrainingEntities();
Data _data = new Data(); //Model

我想把表的数据显示到kendo grid。在 Controller 中,我使用以下代码:

public ActionResult Index()
{
List<Movie> dataForGrid= _dbContext.Movies.ToList();
return View(dataForGrid);
}

最佳答案

相似

在CategoryController.cs中

private Entities db = new Entities(); 
public ActionResult GetItemCategories(GridParams g, string title)
{
title = (title ?? "").ToLower();
Expression<Func<tbl_Category, bool>> ff = i => i.Name.ToLower().Contains(title);


var rs = db.tbl_Category.AsExpandable().Where(ff).OrderBy(o => o.Name);
return Json(new GridModelBuilder<Models.tbl_Category>(rs, g) { }.Build());
}

在 Index.cshtml 中

@Html.Awe().Grid("grid_Category").Columns(
new Column { Name = "ID", Width = 55, Groupable = false, },
new Column { Name = "Name" },
new Column { Name = "NameDisplay" },
new Column { Name = "SortID" },
new Column { ClientFormat = editFormat, Width = 48 },
new Column { ClientFormat = deleteFormat, Width = 48 }
).Url(Url.Action("GetItemCategories", "Category")).Persistence(Persistence.Session
).Sortable(true
).Groupable(false).SingleColumnSort(true
).ShowGroupedColumn(false
).Height(200
).MinHeight(100
).PageSize(10).Parent("txtTitle", "title")

关于c# - 如何绑定(bind)剑道网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18528709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com