Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqGrid未显示有效的json_Json_Jqgrid_Jsonp - Fatal编程技术网

jqGrid未显示有效的json

jqGrid未显示有效的json,json,jqgrid,jsonp,Json,Jqgrid,Jsonp,在阅读了大部分问题并试图找到答案后,我想我放弃了 因此,我遇到的问题与其他人遇到的问题一样,即jqGrid没有显示从SpringMVCServlet接收到的有效json 这是我的json: { "firstRecordIndex": 0, "pageSize": 20, "sortDirection": { "name": "descending", "code": 1 }, "sortCriterion": "id",

在阅读了大部分问题并试图找到答案后,我想我放弃了

因此,我遇到的问题与其他人遇到的问题一样,即jqGrid没有显示从SpringMVCServlet接收到的有效json

这是我的json:

{
    "firstRecordIndex": 0,
    "pageSize": 20,
    "sortDirection": {
        "name": "descending",
        "code": 1
    },
    "sortCriterion": "id",
    "pageNumber": 1,
    "objectsPerPage": 20,
    "fullListSize": 1,
    "searchId": null,
    "totalPages": 1,
    "index": 0,
    "list": [
        {
            "issueNumber": "ABC-6799",
            "entryDate": 1345763592879,
            "billingType": "Non-Billable",
            "notes": "Hello",
            "customer": "XYZ",
            "id": 1,
            "hours": 5,
            "userName": "John Doe"
         }
    ]
}
这是我的jqGrid:

jQuery(function(){ 
  jQuery("#list").jqGrid({
    url:"http://localhost:8080/worktime/timesheet.html?type=list&ajax=true",
    datatype: "json",
    colNames:["User", "Hours", "Date", "Billing Type", "Notes"],
    colModel :[ 
      {name:"userName", width:90, editable:false, jsonmap:"userName", editoptions:{readonly:true,size:10}},
      {name:"hours",  width:55, editable:true, jsonmap:"hours", editoptions:{size:10}}, 
      {name:"entryDate", width:90, editable:true, jsonmap:"entryDate", formatter:"date", "formatoptions":{"srcformat":"m/d/Y", "newformat":"m/d/Y"}, 
          editoptions:{size:12, dataInit:function(el){jQuery(el).datepicker({dateFormat:"m/d/y"});},defaultValue: "m/d/y"}
      },
      {name:"billingType", width:100, editable:true, jsonmap:"billingType", edittype:"select", editoptions:{value:"INV:Billable-Invoice;TSA:Billable-TSA;NON:Non-Billable;OH:Overhead"}},
      {name:"notes", width:150, sortable:false, editable: true, jsonmap:"notes", edittype:"textarea", editoptions:{rows:"2",cols:"20"}} 
    ],
    pager: "#pager",
    rowNum:10,
    rowList:[10,20,30],
    sortname: "entryDate",
    sortorder: "asc",
    jsonReader: {
    root: "list",
    total: "totalPages",
    page: "pageNumber",
    records: "fullListSize",
    repeatitems: false,
    id: "0"
    },
    caption: "Timesheet History",
    viewrecords: true,
    gridview: true,
  });

正确的jqGrid配置是什么?我使用的是jqGrid 4.4.0和jQuery 1.7.2。非常感谢你的帮助。谢谢

为什么会有这个:
id:“0”

您的
jsonReader
应该是:

jsonReader: {
  root: "list",
  total: "totalPages",
  page: "pageNumber",
  records: "fullListSize",
  repeatitems: false,
  id: "id"
}

我问这个问题已经四年多了,我刚刚看到了这个答案。我的道歉。。。我不太记得这个问题是如何解决的,但我希望看到你的答案。谢谢你的回复!