显示我的jqGrid
,但它没有显示我检查过json源的数据,而且没关系
$(document).ready(function () {
$("#grid").jqGrid(
{
url: 'GetDepartment',
datatype: 'json',
mtype: 'GET',
colNames: ['Department ID', 'Department Name'],
colModel: [
{ name: 'DepartmentID', index: 'DepartmentID' },
{ name: 'DepartmentName', index: 'DepartmentName'}
],
pager: $("#GridPager"),
rowNum: 2,
rowList: [5, 10, 15, 20],
width: 'auto',
sortname: 'DepartmentID',
sortorder: "ASC"
})
$("#grid").jqGrid('navGrid', '#GridPager', { add: false, edit: false, del: false, search: false})
})
答案 0 :(得分:0)
我认为你缺少jsonReader,将以下代码添加到你的网格
jsonReader: {
repeatitems: false
id: "DepartmentID"
},
查看预期的json格式的wiki
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data
所以在你的情况下,json响应应该是
{ "rows":[{"DepartmentID":2,"DepartmentName":"Asset Mgmt Group "},{"DepartmentID":16,"DepartmentName":"Business Solutions Group"},{"DepartmentID":8,"DepartmentName":"CBMG"}] }