2

我已经创建了 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);
        }
4

1 回答 1

1

相似的

在 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")
于 2013-09-27T15:37:14.910 回答