[英]jqGrid data not showing but rows are generating
我正在研究MVC應用程序。 我在aspx頁面寫了一個jqGrid。
$(document).ready(function () {
jQuery("#jqgajax").jqGrid({
url: 'http://localhost:54136/home/fetchData',
datatype: "json",
colNames: ['ProcessName', 'WorkingSet64'],
colModel: [
{ name: 'ProcessName', index: 'ProcessName', width: 55 },
{ name: 'WorkingSet64', index: 'WorkingSet64', width: 90 }
],
rowNum: 80,
mtype:'Get',
width: 700,
rowList: [10, 20, 30],
sortname:'id',
viewrecords: true,
sortorder: "desc",
caption: "New API Example"
});
});
控制器的C#代碼:
var jsonData = new
{
total =10,
page = 10,
records = 10,
rows = (
from p in pu
select new
{
id = ++counter,
cell = new
{
ProcessName = p.ProcessName.ToString(),
WorkingSet64 = p.Memory.ToString()
}
}).ToArray()
};
return Json(jsonData,JsonRequestBehavior.AllowGet);
行在網格中生成的問題,但行中沒有數據。
請讓我知道我做錯了什么。
默認的jsonReader將cell
作為字符串數組。 所以你應該替換代碼的一部分
cell = new
{
ProcessName = p.ProcessName.ToString(),
WorkingSet64 = p.Memory.ToString()
}
至
cell = new [] { p.ProcessName, p.Memory.ToString() }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.