簡體   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