1. 程式人生 > >JQGRID讀取json資料的格式要求

JQGRID讀取json資料的格式要求

 
* jqGrid預設期望返回的json物件格式要求如下:
* {"page":"1","total":"2","records":"13",
* "rows":[
* {id:"1",cell:["1","polaris","男","[email protected]","772618379","18329382732","1985-10-2"]},
* {id:"2",cell:["2","張三","女","[email protected]","272618382","15329382732","1986-10-12"]},
* {id:"3",cell:["3","王五","女","
[email protected]
","172635372","13329389832","1987-12-21"]}, * {id:"4",cell:["4","趙六","男","[email protected]","372618332","18929343731","1988-09-22"]} * ] * } * 當然,在js中,可以通過jqGrid的jsonReader屬性來修改預設格式 * 因為預設的格式,rows的資料要求順序不能變,且每個欄位都得有值(空也得有"")。因而, * 在jsonReader中定義repeatitems : false。這樣,rows就變成了: * "rows":[ * {id:"1",userName:"polaris",gender:" 男",email:"
[email protected]
",QQ:"772618379",mobilePhone:"18329382732",birthday:"1985-10-2"]}, * {id:"2",userName:"徐新華",gender:" 男",email:"[email protected]",QQ:"272618382",mobilePhone:"15329382732",birthday:"1986-10-12"]}, * {id:"3",userName:"王五",gender:" 女",email:"[email protected]",QQ:"172635372",mobilePhone:"13329389832",birthday:"1987-12-21"]}, * {id:"4",userName:"趙六",gender:" 女",email:"
[email protected]
",QQ:"372618332",mobilePhone:"18929343731",birthday:"1988-09-22"]} * ] * */