Asp.net-Mvc-3

插入命令需要插入數據綁定設置 Kendo Grid Error any

  • January 13, 2015

劍道網格顯示以下錯誤

插入命令需要插入數據綁定設置。請在 DataBinding 配置中指定插入操作或 url

@(Html.Kendo().Grid<Pa.Portal.KazangService.KazangAccount>()
   .Name("grids")
   .Columns(columns =>
   {
       columns.Bound(g => g.Id);
       columns.Bound(g=>g.UserName);
       columns.Bound(g=>g.Password);
       columns.Bound(g=>g.Channel);
      
   })
   .ToolBar(toolbar => toolbar.Create()) 
   .Pageable()
   .Sortable()
   .Scrollable()
   .AutoBind(true)
   .HtmlAttributes(new { style = "height:430px;" })
   .DataSource(dataSource => dataSource
       .Ajax()
       .PageSize(20)      
       .Model(m => m.Id(h => h.Id))      
       .Read(read => read.Action("LoadAllkazangAccounts", "Kazang"))    
       ))

CONTROLLER


 public ActionResult LoadAll([DataSourceRequest] DataSourceRequest request)
       {
           IKazangBusinessService client = PaChannelFactory<IKazangBusinessService>.Default.CreateChannel();
           IEnumerable<KazangAccount> KaList = client.GetAllKazangAccounts().ToList();
           ((IChannel)client).Close();
           return Json(KaList.ToDataSourceResult(request));
       }

您收到此錯誤的原因在於您在工具欄中添加了“創建”按鈕。

將此添加到網格後,數據源部分正在尋找創建命令路徑。

例如。對於您的閱讀操作

.Read(read => read.Action("LoadAllkazangAccounts", "Kazang"))   

因此您需要添加適當的插入操作,例如:

.Create(create=> create.Action("CreatekazangAccounts", "Kazang"))   

如果您不需要在此網格中創建任何內容,則只需從網格中刪除創建工具欄菜單項。

引用自:https://stackoverflow.com/questions/27841894