我想将 jqGrid 集成到 asp.net 网页中。我得到了 JSON 格式的数据。但是在渲染没有数据的页面网格时。
我的书面代码如下。
JqGridExample.aspx
jQuery("#jsonmap").jqGrid({
url: 'GetData.aspx',
datatype: 'json',
colNames: ['ID', 'Name', 'Active', 'Gender'],
colModel: [
{ name: 'id', index: 'id', width: 35, editable: false, editoptions: { readonly: true, size: 10} },
{ name: 'name', index: 'name', width: 150, align: "left", editable: true, size: 100 },
{ name: 'isClosed', index: 'isClosed', width: 100, align: 'left', editable: true, edittype: "checkbox", editoptions: { value: "true:false", formatter: "checkbox"} },
{ name: 'gender', index: 'gender', width: 100, formatter: 'select', editable: true, edittype: "select", editoptions: { value: "0:select;1:male;2:female"} }
],
rowNum: 10,
rowList: [2, 5, 10, 15],
pager: '#pjmap',
sortname: 'id',
sortorder: "desc",
viewrecords: true,
jsonReader: { repeatitems: false, cell: "", id: "0" },
width: 600,
caption: 'First jqGrid',
height: '100%', viewrecords: true, fixed: true, gridview: true, loadonce: true
});
<table id="jsonmap">
</table>
<div id="pjmap">
</div>
我从中得到的数据getdata.aspx
是
{"total":1,"page":1,"records":5,"rows":[{"Name":"John","Id":1,"Gender":1,"IsClosed":false},{"Name":"Abel","Id":2,"Gender":1,"IsClosed":false},{"Name":"Aaron","Id":3,"Gender":1,"IsClosed":true},{"Name":"Tsion","Id":4,"Gender":2,"IsClosed":true},{"Name":"Mussie","Id":5,"Gender":2,"IsClosed":true}]}
在 jqGridExample.aspx 数据上的渲染网格未显示。
提前致谢..