2016-04-22 19 views
-1

大括弧で囲んだAPIにこのコードを使用しました。しかし、それはこのようになりますAPIのために動作しません:私はそれをあきらめた jqGridは角括弧なしのJSONを読み取らない

function loadMaterialDetails(id) { 
    $("#materialDetails").jqGrid("GridUnload"); 

    $("#materialDetails").jqGrid({ 
     url: url, 
     mtype: "GET", 
     datatype: "json", 
     colModel: [ 
      { label: 'Material ID',  name: 'ID', key: true, width: 1 }, 
      { label: 'Material Name', name: 'name', width: 2 }, 
      { label: 'Supplier',  name: 'supplier', width: 2 }, 
      { label: 'Description',  name: 'description', width: 3 }, 
      { label: 'Notes',   name: 'notes', width: 1 }, 
      { label: 'Price',   name: 'price', width: 1 }, 
      { label: 'Currency',  name: 'currency', width: 1 } 
     ], 
     viewrecords: true, 
     width: 780, 
     height: 250, 
     rowNum: 20, 
     onSelectRow: function(id){ 
      alert(id); 
    } 
}); 

UPDATE:ここ

{"name":"Summer Tire","description":"Premium Summer Tires.","notes":"Good price","supplier":"Tire Systems","price":79,"currency":"EUR","ID":2} 

は私のコードです。取得できる行が1つしかないことが分かっている場合は、getJSONを使用して取得し、手動で操作します。入力してくれてありがとう!

+0

グリッドには、返される行の配列が必要です。明らかに、あなたのAPIは単一の行だけを返しています。 – Cerbrus

+0

私はそれを見ましたが、どういうわけか、それを1行表示にすることはできますか? – Haruspik

+0

バックエンドコードはどのように見えますか? – madalinivascu

答えて

関連する問題