2011-08-01 3 views
1

ドットが "。"のプロパティを持つjsonがあります。その中のオペレータ。 私のグリッドをレンダリングしようとすると、何もエラーなしで空白になります。これは私のcolModeljquery jqgridプロパティとドット演算子

colModel : [ { 
     name : 'service.name', 
     search : 'true', 
     editable : true, 
     //index : 'service.name', 
     width : 200, 
     jsonmap : "cell.service.name"   
    }, 
    { 
     name : 'function.code', 
     search : 'true', 
     editable : true, 
     sortable:true, 
     //index : 'function.code', 
     width : 200, 
     jsonmap : "cell.function.code"   
    }], 

JSONリーダーである

{ 
      "total":1, 
     "page":1, 
     "records":2, 
     "rows":[{ 
       "id":2110040, 
       "cell":{ 
       "function.code":"dsadad", 
         "service.name":"dsadasda" 

       } 
      }, 
      { 
       "id":2115040, 
       "cell":{ 
       "function.code":"iuiyuiy", 
        "service.name":"iyuiyuiy" 

       } 
      } 
     ] 
    } 

はここに私のJSONだ

jsonReader : { 
     repeatitems : false, 
     root : "rows", 
     cell : "cell", 
     id : "id", 
     page : "page", 
     records : "records" 
    }, 

助けてください、私はここで何をしないのです??

ありがとうございます!

答えて

1

を試してみてください。 hereの問題に近いですが、XMLではなくJSONの場合です。

問題は、jqGridがobj.cell['function.code']の代わりにobj.cell.function.codeの行を読み取ろうとしていることです。あなたはthe demoアプローチの仕事に見ることができますどのように

colModel: [ 
    { 
     name: 'service_name', 
     search: 'true', 
     editable: true, 
     width: 200, 
     jsonmap: function (obj) { 
      return obj.cell['service.name']; 
     } 
    }, 
    { 
     name: 'function_code', 
     search: 'true', 
     editable: true, 
     sortable: true, 
     width: 200, 
     jsonmap: function (obj) { 
      return obj.cell['function.code']; 
     } 
    } 
] 

:jqGridが正しくあなたがjsonmapとして機能を使用することができ、データを読み取ることができるようにします。

+0

それはうまくいった!オレグに感謝します。 – user620339

+0

@ user620339:ようこそ! – Oleg

+0

@ user620339:ところで[別のデモ](http://www.ok-soft-gmbh.com/jqGrid/user620339_old.htm)[あなたの古い答え](http://stackoverflow.com/questions/6853457)/jquery-jqgrid-renders-empty-table/6905206#6905206)も動作します。 – Oleg

0

は、私はあなたが興味深い質問を見つけるこの

colModel : [ { 
     name : 'service.name', 
     search : 'true', 
     editable : true, 
     //index : 'service.name', 
     width : 200, 
     jsonmap : 'cell["service.name"]'   
    }, 
    { 
     name : 'function.code', 
     search : 'true', 
     editable : true, 
     sortable:true, 
     //index : 'function.code', 
     width : 200, 
     jsonmap : 'cell["function.code"]'   
    }], 
+0

シャンカー、私はこれを試しましたが、同じブランクのグリッドを手に入れました! – user620339

+0

私の編集した答えを参考にしてみてください。 – ShankarSangoli

+0

これも試してみて、うまくいきません!! – user620339

関連する問題