2014-01-07 34 views
0

我遇到了網格問題。當我打的編輯按鈕編輯行的內容,我得到了以下JavaScript錯誤:編輯Telerik MVC Grid中的行時出錯

線:1個 錯誤:「數據(...)」爲空或不是對象

錯誤點回到telerik.grid.editing.min.js。我已經在我的網站的其他部分完成了內聯編輯,但是,由於某種原因,這個內容正在吐出這個錯誤。這裏是我的部分觀點,代碼在於。

@model CycleCountModel 
@using Telerik.Web.Mvc.UI; 

<div id="divGrid"> 
    @(Html.Telerik().Grid<CycleCountProductModel>() 
     .Name("cyclecountproducts-grid") 
     .DataKeys(keys => 
     { 
      keys.Add(x => x.CycleCountId); 
     }) 
     .DataBinding(dataBinding => 
     { 
      dataBinding.Ajax() 
       .Select("_CycleCountProductGrid", "CycleCount", Model) 
       .Update("_CycleCountProductUpdate", "CycleCount") 
       .Delete("_CycleCountProductDelete", "CycleCount"); 
     }) 
     .ClientEvents(events => 
     { 
      events 
       .OnDataBinding("onDataBinding"); 
     }) 
     .Columns(columns => 
     { 
      columns.Bound(x => x.CycleCountId) 
       .Hidden(true); 
      columns.Bound(x => x.ProductId) 
       .Hidden(true); 
      columns.Bound(x => x.ItemNumber) 
       .ReadOnly(true); 
      columns.Bound(x => x.ProductName) 
       .ReadOnly(true); 
      columns.Bound(x => x.CategoryName) 
       .ReadOnly(true); 
      columns.Bound(x => x.PrimaryLocation) 
       .ReadOnly(true); 
      if (Model.Id == 0) 
      { 
       columns.Bound(x => x.LastCountedDate) 
        .ReadOnly(true); 
      } 
      if (Model.Id != 0) 
      { 
       columns.Bound(x => x.Sublocations) 
        .ReadOnly(true); 
       columns.Bound(x => x.Measure) 
        .ReadOnly(true); 
       columns.Bound(x => x.SystemStockQuantity) 
        .ReadOnly(true); 
       columns.Bound(x => x.ShelfStockQuantity); 
       if (Model.Status == 1) 
       { 
        columns.Command(commands => 
        { 
         commands.Edit(); 
         commands.Delete(); 
        }); 
       } 
      } 
     }) 
     .Pageable() 
     .EnableCustomBinding(true)) 
</div> 

相比我以前的工作,這是相似的。我真正唯一的區別就是顯示網格的部分(這個網格在網站的其他區域重用,因此爲什麼要檢查狀態)。有些方向將不勝感激。

+0

刪除clientevent並檢查控制器的數據操作 – user1956570

+0

這沒有幫助。除此之外,當你點擊編輯按鈕時,爲什麼會有一個呼叫出現在控制器上?這是一個客戶端事件,而不是服務器。 – IyaTaisho

回答

0

我發現了這個問題。我有我的CycleCountId和ProductId,我只有他們隱藏。當我給他們添加一個Readonly時,錯誤消失了。現在我想到它是有道理的。然而,至少可以說是令人討厭的。

相關問題