我的情景:
我有一个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');
}
});
});
答案 0 :(得分: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,要么你没有设置成功/总数。
编辑:乍一看,它看起来好像是从服务器返回一个数组,而不是将记录包装在一个对象中,如上所示。