2012-08-25 52 views
0

閱讀大部分問題並試圖找到答案後,我想我放棄了。jqGrid沒有顯示有效的json

所以我遇到的問題就像其他人一直有的一樣,也就是說,jqGrid不顯示從spring mvc servlet接收到的有效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。非常感謝您的幫助。謝謝!!

回答

0

爲什麼你有這個:id: "0"

jsonReader大概應該是:

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

它已經4年多了,因爲我問這個問題,我剛纔看到這個答案。我的歉意......我不記得這個問題是如何解決的,但我希望我能看到你的答案。感謝您的答覆! –