2016-04-05 27 views
0

我的場景:
我有一個w2ui數據網格,數據通過調用Rest api來自遠程服務器。
我可以在瀏覽器調試器中看到響應數據,但不能在網格中看到。
請幫忙。下面我的代碼和Firebug快照。那裏的數據,但在網格中不可見

非常感謝您的任何提示。

 $(function() { 
     $('#grid').w2grid({ 
      method: 'GET', 
      crossDomain: true, 
      url: 'https://im-dev....net/bp/development/DETDS/Claims' + sSomeIds + sSession, 
      dataType: 'json', 
      name: 'grid', 
      recid: 'clmNumber', 
      show: { 
       selectColumn: true, 
       toolbar: true, 
       footer: true, 
       toolbarSave: true 
       //toolbarAdd: true 
      }, 
      columns: [ 
       {field: 'busUnit', caption: 'busUnit', size: '150px'}, 
       {field: 'catCodeC', caption: 'catCodeC', size: '150px'}, 
       {field: 'clmStatus', caption: 'clmStatus', size: '150px'}, 
       {field: 'clmStatusDesc', caption: 'Status', size: '150px'}, 
       {field: 'ctryCd', caption: 'Country', size: '100px'}, 
       {field: 'ctryDesc', caption: 'ctryDesc', size: '100px'}, 
       {field: 'department', caption: 'department', size: '80px'}, 
       {field: 'empName', caption: 'Requester', size: '140px'}, 
       {field: 'empcnum', caption: 'empcnum', size: '80px'}, 
       {field: 'enddate', caption: 'enddate', size: '80px'}, 
       {field: 'flmrgScr', caption: 'flmrgScr', size: '80px'}, 
       {field: 'groupCode', caption: 'groupCode', size: '80px'}, 
       {field: 'histScr', caption: 'histScr', size: '80px'}, 
       {field: 'imt', caption: 'IMT', size: '80px'}, 
       {field: 'iot', caption: 'IOT', size: '80px'}, 
       {field: 'mgrcnum', caption: 'mgrcnum', size: '80px'}, 
       {field: 'mgrname', caption: 'FLM', size: '140px'}, 
       {field: 'submitdate', caption: 'submitdate', size: '80px'}, 
       {field: 'clmNumber', caption: 'clmNumber', size: '80px'}, 
       {field: 'tepeScr', caption: 'tepeScr', size: '80px'}, 
       {field: 'tranScr', caption: 'tranScr', size: '80px'} 
      ], 
      onSubmit: function (event) { 
       w2alert('save'); 
      }    
     });   
    }); 

FireBug snapshot >>>here<<<.

回答

0

究竟做您的網址回報?

您是否閱讀了有關預期結構的文檔?

http://w2ui.com/web/docs/grid/overview#data-structures

{ 
    "status" : "success", 
    "total" : 36, 
    "records" : [ 
     { "recid": 1, "field-1": "value-1", ... "field-N": "value-N" }, 
     ... 
     { "recid": N, "field-1": "value-1", ... "field-N": "value-N" } 
    ] 
} 

我的猜測是,你要麼不給每個記錄的唯一recid,或者你沒有設置成功/總。

編輯:乍一看,它看起來好像從服務器返回一個數組,而不是如上所示將對象中的記錄包裝在一個對象中。

+0

嗨Waldemar。就像我所說的,服務器必須以描述的形式發送JSON。在網格上設置recid是不好的。每個記錄必須具有唯一的recid屬性。 –

+0

嗨邁克,在我看來,我得到了一個完美的JSON作爲迴應。因此我驚訝。我的代碼我把recid設置爲:recid:'clmNumber',是不是還是不夠?但是,是的,在回覆中沒有總數和recid。你認爲這是一個問題嗎? – Waldemar

+0

無論如何,我會按照你的建議,改變json結構,然後再測試。 – Waldemar

相關問題