日期:2014-05-16  浏览次数:20303 次

jqgrid 不显示数据 可能是自定义接收JSON的格式的问题,大家帮我看一看



$(function() {
jQuery("#grid").jqGrid({
    url: templateRoot + '/one/oneAction_page.do',
datatype: "jsonstring",
autowidth: true,
viewrecords: true,
jsonReader:{
repeatitems: false,
total: "lastPageNo",
page: "pageNo",
records: "totalCount",
root: "list"
},
prmNames : {  
    page:"pageNo",    // 表示请求页码的参数名称  
    rows:"pageSize",    // 表示请求行数的参数名称  
    sort: "sort", // 表示用于排序的列名的参数名称  
    order: "dir" // 表示采用的排序方式的参数名称  
},
    colModel:[
    {name:'id',index:'id', width:55},
    {name:'name',index:'name', width:100},
    {name:'age',index:'age', width:150}
    ],
    rowNum:10,
    rowList:[10,20,30],
    caption:"JSON wat"
});

});



{"pageNo":1,"pageSize":4,"list":[{"age":"1","id":"1","name":"?"},{"age":"2","id":"16c798763c4541138db69f02674183a0","name":"?"},{"age":"3","id":"2","name":"?"},{"age":"4","id":"3","name":"?"}],"totalCount":8,"totalPage":2,"success":true}



------解决方案--------------------
jsonstring和json类型注意
 //datatype: "jsonstring",

//===>
 datatype: "json",


或者
 //url: templateRoot + '/one/oneAction_page.do',
             datastr: '{"pageNo":1,"pageSize":4,"list":[{"age":"1","id":"1","name":"?"},{"age":"2","id":"16c798763c4541138db69f02674183a0","name":"?"},{"age":"3","id":"2","name":"?"},{"age":"4","id":"3","name":"?"}],"totalCount":8,"totalPage":2,"success":true}',
             datatype: "jsonstring",