使用Ajax调用将数据映射到JQGrid

时间:2016-09-27 20:00:19

标签: ajax vb.net jqgrid

我只是想显示一个非常简单的JQGrid,其中包含从ajax调用到控制器的数据。我所看到的只是网格标题,没有数据。有人可以帮我弄清楚我做错了什么吗?提前谢谢!

这是Ajax调用和JQGrid设置..

#! /usr/bin/env python3

ans = input( 'Enter URL: ' )
# do something based on $ans
print( 'Verification code: AIwquj2VVkwlWEBwway' )
print( 'Access Token: bskjZO8iZotv!' )

这是控制器代码......

$("#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"
        });

1 个答案:

答案 0 :(得分:1)

主要问题:rowdata应该是数组项目(对象数组),而不是一个对象只有Name和{{ 1}}属性。

此外,您应该决定是否实施服务器端分页数据,或者您希望立即从RandomStuff返回所有数据并且jqGrid应该< em>本地分页,排序和过滤/排序数据?在这种情况下,您应该使用GetLoanReport选项。此外,选择jqGrid的分支很重要,您可以使用它:free jqGrid,商业Guriddo jqGrid JS或版本中的旧jqGrid&lt; = 4.7。我开发了免费的jqGrid fork,我可以推荐你。如果您使用它,我建议您另外向loadonce: true添加forceClientSorting: true选项。它允许您使用loadonce: truesortname选项对服务器返回的数据进行排序,然后才会显示