0

我正在尝试使用 HtmlHelper 扩展来实现 Kendo Grid

我的控制器类是“Store”,视图是“viewStores”,我正在尝试使用方法“StoreRead”绑定数据。我正在使用 Visual Studio 2012、.net 4.5 和 mvc 4 和剃须刀......

这是我的代码..

   public ActionResult viewStores()
{
   //return View(GetStores());
    return View();
}

public ActionResult StoreRead([DataSourceRequest] DataSourceRequest request)
 {
    return Json(GetStores().ToDataSourceResult(request));
 }

private static IEnumerable<Store> GetStores()
{
    var db_store = new AppContext();

    return db_store.Stores.Select(store => new Store
    {
        storeID = store.storeID,
        address = store.address,
        postcode = store.postcode,
        city = store.city,
        Country = store.Country
    });

}

看法

@model KendoAspNetBundles.Models.Store

<h2>viewStores</h2>

@(Html.Kendo().Grid<KendoAspNetBundles.Models.Store>()
  .Name("Grid")
  .Columns(columns =>
{
columns.Bound(s => s.storeID);
columns.Bound(s => s.address);
columns.Bound(s => s.postcode);
columns.Bound(s => s.city);
columns.Bound(s => s.Country);
})
 .DataSource(dataSource => dataSource
   .Ajax() 
   .Read(read => read.Action("StoreRead", "Store")) 
 )
.Pageable()
 )

模型

 public class Store
 {
   public int storeID { get; set; }
   public string address { get; set; }
   public string postcode { get; set; }
   public string city { get; set; }
   public string Country { get; set; }
  }
4

0 回答 0