2014-10-09 271 views
0

我使用jqGrid顯示一些json數據,但當我運行代碼時,網格不顯示任何東西,我收到沒有錯誤消息在我的控制檯中。
這裏是我的js代碼:jqGrid不顯示JSON數據

$("#gridWall").jqGrid({ 
    datatype: 'json', 
    data: data, 
    colNames: ['Id', 'Title', 'Artist', 'ISRC'], 
    colModel: [ 
       {name: 'Id', index: 'music_video_id', width: 100, editable: false}, 
       {name: 'Title', index: 'title', width: 150, editable: false}, 
       {name: 'Artist', index: 'artist_name', width: 200, editable: false}, 
       {name: 'ISRC', index: 'isrc', width: 150, editable: false} 

    ], 
    pager: '#gridpagerWall', 
    loadonce: true, 
    rowNum: 100, 
    rowList: [100, 200, 300], 
    sortname: 'title', 
    sortorder: 'asc', 
    jsonReader: { 
     repeatitems: true, 
     root: "contents", 
     page: '1', 
     total: "number" 

    }, 
    viewrecords: true, 
    gridview: true, 
    hidegrid: false, 
    caption: 'Wall builder', 
    editUrl: 'clientArray', 
    }) 

我的JSON數據是這樣的:

{"number":50,"type":5,"contents":[{"title":"xxx","isrc":"xxx","artist_name":"xx","music_video_id":"1"},...]} 

有誰知道我怎樣才能解決我的問題?
謝謝

回答

0

檢查你的json有效使用json Validator
然後將data:data,更改爲url :data
我希望變量數據包含有效的url。