2010-07-14 77 views
1

我剛剛下載的jQuery網格ASP.NET MVC的CodePlex從的jQuery網格的MVC數據未從控制器來查看

我並運行該項目,所有接縫就可以了吧,在SQL事件探查器,我可以看到, SQL查詢來的數據庫。然後在調試器中,我可以看到數據來自LinqToSql查詢罰款:

var model = from entity in repository.Index().OrderBy(sidx + " " + sord) 
    select new 
    { 
     Edit = "_edit link was here_", 
     Details = "_details link was here_", 
     ProductID = entity.ProductID, 
     ProductName = entity.ProductName, 
     UnitPrice = entity.UnitPrice, 
     Discontinued = entity.Discontinued == true 
      ? "<input type='checkbox' checked='checked' disabled='disabled'/>" 
      : "<input type='checkbox' disabled='disabled' />" 
    }; 

數據來模型,模型不爲空。

然後這個數據轉換到JSON,然後JsonResult進去觀點:

JsonResult jData = Json(model.ToJqGridData 
    (page, rows, null, search, new[] { "ProductName" })); 
return jData; 

我在調試器看到的,存在jData數據,jData不爲空,一切看起來很不錯。

但是在視圖(html)上沒有數據顯示在jqGrid上,它是空的。由於某些原因數據不從控制器來查看(的jqGrid)。 我嘗試所有最新的瀏覽器。

我認爲JavaScript中藏在什麼地方的問題,目前我期待在此。

可能有人想過這事任何想法。

+0

沒錯,問題是在你的JavaScript。 – 2010-07-14 08:50:42

回答

1

您必須添加 'JsonRequestBehavior.AllowGet' 在JSonDataController,功能列表如下:

return Json(model.ToJqGridData(page, rows, null, "", 
      new[] { "ProductName", "UnitPrice" }), JsonRequestBehavior.AllowGet); 
相關問題