数据在那里,但在网格中不可见
Data there, but not visible in grid
我的场景:
我有一个 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');
}
});
});
你的 url return 究竟是什么?
您是否阅读了有关预期结构的文档?
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,要么您没有设置 success/total。
编辑:乍一看,您似乎是在 return 从服务器获取数组,而不是将记录包装在对象中,如上所示。
我的场景:
我有一个 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');
}
});
});
你的 url return 究竟是什么?
您是否阅读了有关预期结构的文档?
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,要么您没有设置 success/total。
编辑:乍一看,您似乎是在 return 从服务器获取数组,而不是将记录包装在对象中,如上所示。