我正在使用 jqgrid,我想从 jquery 显示网格调用控制器返回我的 json 数据我的网格没有显示数据代码在这里
public JsonResult GetPlainobjectAsJson()
{
var rows = (getdatalist()
.Select(c => new
{
id = c.CatId,
cell = new []
{
c.CatId.ToString(),
c.CatName,
c.desc,
c.desc1,
c.desc10,
c.desc11,
c.desc12,
c.desc13,
c.desc14,
c.desc15,
c.desc16,
c.desc17,
c.desc18,
c.desc19,
c.desc2,
c.desc20,
c.desc21,
c.desc22,
c.desc23,
c.desc24,
c.desc25,
c.desc3,
c.desc4,
c.desc5,
c.desc6,
c.desc7,
c.desc8,
c.desc9,
c.ProId.ToString(),
c.ProName
}
})).ToArray();
return new JsonResult
{
Data = new
{
page = 1,
records = rows.Length,
rows,
total = 1
}
};
}
这个函数生成json数据和这个函数
返回json结果
public JsonResult GetPlainobject()
{
var res = GetPlainobjectAsJson();
return Json(res, JsonRequestBehavior.AllowGet);
}
这是索引页
<script type="text/javascript">
$(document).ready(function () {
debugger;
$("#treegrid").jqGrid({
url: '@Url.Content("~/TreeGrid/GetPlainobject")',
datatype: "json",
mtype: "Get",
colNames: ["CatId", "CatName", "desc", "desc1", "desc10", "desc11", "desc12", "desc13", "desc14", "desc15", "desc16", "desc17", "desc18",
"desc19", "desc2", "desc20", "desc21", "desc22", "desc23", "desc24", "desc25", "desc3", "desc4", "desc5", "desc6",
"desc7", "desc8", "desc9", "ProId", "ProName"],
colModel: [
{ name: "CatId", index: "CatId", width: 150, key: true },
{ name: "CatName", index: "CatName", width: 200 },
{ name: "desc", index: "desc", width: 200 },
{ name: "desc1", index: "desc1", width: 300 },
{ name: "desc10", index: "desc10", width: 300 },
{ name: "desc11", index: "desc11", width: 150 },
{ name: "desc12", index: "desc12", width: 200 },
{ name: "desc13", index: "desc13", width: 300 },
{ name: "desc14", index: "desc14", width: 150 },
{ name: "desc15", index: "desc15", width: 200 },
{ name: "desc16", index: "desc16", width: 300 },
{ name: "desc17", index: "desc17", width: 150 },
{ name: "desc18", index: "desc18", width: 200 },
{ name: "desc19", index: "desc19", width: 300 },
{ name: "desc2", index: "desc2", width: 150 },
{ name: "desc20", index: "desc20", width: 150 },
{ name: "desc21", index: "desc21", width: 200 },
{ name: "desc22", index: "desc22", width: 300 },
{ name: "desc23", index: "desc23", width: 150 },
{ name: "desc24", index: "desc24", width: 200 },
{ name: "desc25", index: "desc25", width: 300 },
{ name: "desc3", index: "desc3", width: 200 },
{ name: "desc4", index: "desc4", width: 300 },
{ name: "desc5", index: "desc5", width: 150 },
{ name: "desc6", index: "desc6", width: 200 },
{ name: "desc7", index: "desc7", width: 300 },
{ name: "desc8", index: "desc8", width: 150 },
{ name: "desc9", index: "desc9", width: 200 },
{ name: "ProId", index: "ProId", width: 300 },
{ name: "ProName", index: "ProName", width: 150 }
],
height: "auto",
rowNum: 10,
rowList: [10, 20, 30],
pager:"#pager",
gridview: true,
viewrecords: true,
caption: "Tree Grid Example",
jsonReader : {
root: "Data",
page: "page",
total: "total",
records: "records"
}
});
});
</script>
帮我在哪里我错了....