2016-04-14 29 views
0

jqGridをしばらく使用していましたが、クライアントサイドグリッドにデータを返すための新しいサーバーサイドスクリプトを作成しようとしていました。何度も、私はこれらのソフトウェアプログラムの基本に戻ろうとします。 JSONデータをグリッドに戻したいのですが、ポケットベルなしで一度ロ​​ードするだけです。jqgridカスタムJSONデータにエラーはありませんが、データは表示されません

ここ
{ 
    "total": "xxx", 
    "page": "yyy", 
    "records": "zzz", 
    "rows" : [ 
    {"id" :"1", "cell" :["cell11", "cell12", "cell13"]}, 
    {"id" :"2", "cell":["cell21", "cell22", "cell23"]}, 
     ... 
    ] 
} 

はJSグリッドの定義です:ドキュメントhereを参照した後、私はこのように、ドキュメントからのフォーマットに合わせて、私のJSON文字列を作成しようとした私が行っていた

$("#jqGrid").jqGrid({ 
    url:'/dataurl.php', 
    shrinkToFit: true, 
    autowidth: true, 
    datatype: 'json', 
    mtype: 'POST', 
    postData:{ 
     'arg1':'load_data', 
     'num_days':$('#num_of_days_input').val() 
    }, 
    colNames:[ 
     'Ship_Date', 
     'Insert/Label', 
     'Customer', 
     'JobNum', 
     'QNTYOrdered', 
     'DEL', 
     'Ship_Type', 
     'Carrier', 
     'Time', 
     'Status' 
    ], 
    colModel:[ 
     {width:20,name:'Ship_Date', index:'Ship_Date'}, 
     {width:20,name:'InsertorLabel', index:'InsertorLabel'}, 
     {width:20,name:'Customer', index:'Customer'}, 
     {width:20,name:'JobNum', index:'JobNum'}, 
     {width:20,name:'QNTYOrdered', index:'QNTYOrdered'}, 
     {width:20,name:'DEL', index:'DEL'}, 
     {width:20,name:'Ship_Type', index:'Ship_Type', edittype:'select', editoptions:{value:"Partial:Partial;Balance:Balance;Full:Full"}}, 
     {width:20,name:'Carrier', index:'Carrier', edittype:'select', editoptions:{value:"UPS:UPS;Fed Ex:Fed Ex;2D:2D;T&M:T&M;Cougar:Cougar"}}, 
     {width:20,name:'Time', index:'Time', edittype:'select', editoptions:{value:"before 7am:before 7am;7-9am:7-9am;9-12am:9-12am;12-3pm:12-3pm;after 3pm:after 3pm"}}, 
     {width:20,name:'Status', index:'Status', edittype:'select', editoptions:{value:"To Ship:To Ship;Ship Pending:Ship Pending"}} 
    ], 
    loadonce: true, 
    sortname: 'Ship_Date', 
    sortorder: 'asc', 
    viewrecords: true, 
    gridview: true, 
    caption: 'Shipping Request', 
    loadError: function(xhr, status, error){ 
     alert(xhr.responseText); 
     alert(status); 
     alert(error); 
    }, 
    loadComplete: function(data){ 
     alert(JSON.stringify(data, null, 4)); 
    } 
}); 

かなりloadErrorメソッドを使用してデバッグを行いましたが、エラーが発生していないため、サーバーから返されたデータが表示されます。残念ながら、グリッドがまだ空に現れ、

enter image description here

しかし:私にとってそれは形式が正しいかのように見えます。私はまだ何かが欠けていますか?ありがとう!

+0

完全なURLパスを入力して確認してください。 – RJParikh

答えて

1

配列でなければならない、しかし、あなたは(それが"rows": [{}]する必要がありますが、あなたは代わりに"rows": {}を使用)の代わりにオブジェクトを使用サーバからのJSON応答のrowsプロパティの値。 1つのアイテムしか持たない場合でも、そのアイテムの1つで配列を返す必要があります。

+0

いつものように、ありがとう! –

+0

@jeffery_the_wind:あなたは大歓迎です! – Oleg

関連する問題