繁体   English   中英

如何绑定剑道网格

[英]How to bind kendo grid

我创建了asp.net MVC 4应用程序,其中使用实体框架,并且以“数据”类为模型。

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

我想将表的数据显示到剑道网格。 在控制器中,我正在使用以下代码:

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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM