0
我只是试图显示一个非常简单的JQGrid,其中包含从ajax调用到控制器的数据。我看到的只是网格标题,没有数据。有人能帮我弄清楚我做错了什么吗?提前致谢!使用Ajax调用将数据映射到JQGrid
这里的Ajax调用和设置的jqGrid ..
$("#grid").jqGrid({
url: '@Url.Action("GetLoanReport", "Report")',
datatype: "json",
height: "auto",
colNames: ['Name', 'Random Stuff'],
colModel: [
{ name: 'Name', index: 'Name', width: 150, sortable: true },
{ name: 'RandomStuff', index: 'RandomStuff', width: 500, sortable: false }
],
jsonReader: {
repeatitems: true,
root: 'rowdata',
page: 'currpage',
total: 'totalpages',
records: 'totalrecords'
},
rowNum: 10,
rowList: [5, 10, 30],
rownumbers: false,
gridview: true,
loadonce: true,
pager: "#page",
caption: "Flat Data Example"
});
这里的控制器代码...
Function GetLoanReport() As JsonResult
ViewData("Ribbon") = "partials/_statsRibbon"
Dim response As New Response
Dim model As New ReportModel
model.Name = "Mark"
model.RandomStuff = "Highfield"
response.currpage = 1
response.totalpages = 1
response.totalrecords = 1
response.rowdata = model
Return Json(response, JsonRequestBehavior.AllowGet)
End Function
你想实现**服务器端分页**你想从GetLoanReport返回所有的数据,而jqGrid应该使本地*分页,排序和过滤/排序数据?无论如何,'rowdata'应该是** array **项(数组对象),而不是一个**对象**,只有'Name'和'RandomStuff'属性。对不起,我忘了VB的语法。您可以使用哪个版本的jqGrid(可以使用)以及从哪个版本的jqGrid([免费jqGrid](https://github.com/free-jqgrid/jqGrid),商业版[Guriddo jqGrid JS](http:// guriddo) net /?page_id = 103334)或旧版本的jqGrid版本<= 4.7) – Oleg
就是这样。多么令人沮丧,哈哈。我将rowdata设置为对象而不是对象列表。当我将它改为一个完美的对象列表时,它可以完美运行。谢谢! –
不客气!我希望我可以帮助你。我发布了与答案相同的信息,您可以接受并“关闭”问题。 – Oleg