jQuery MiniUI

标题: datagrid中接收到服务器返回的json格式数据不满足规范处理 [打印本页]

作者: buyiyanqi    时间: 2018-11-27 11:18:18     标题: datagrid中接收到服务器返回的json格式数据不满足规范处理

在使用mini-datagrid时,服务端返回是的数据必须是如下格式
{total:11,
data:[
        {url:"BE.ico",name:"比利时"},
        {url:"CZ.ico",name:"捷克"},
]}
但是目前服务端是一一上线运行项目,无法按照现datagrid要求重新构造返回数据,服务端返回数据格式如下:
{
code: "SUCCEED",
data: {
"totalCount": "2",
"list": [
{
"id": "682265633886208",
"status": 1,
"createBy": "",
"createTime": "2018-05-01 16:13:51"
},
{
"id": "4363087427670016",
"status": 1,
"createBy": "",
"createTime": "2018-05-03 15:09:42"
}]
},
"sign": "",
"message": "操作成功",
"isSucceed": true,
"timestamp": "1543283213706"
}
想请教一下,有什么好的办法可以在前端进行重新构造数据,之前是通过ajax方式从服务端获取数据后,采用grdi.setData(data)方式,对datagrid赋值,但是发现当点击datagrid底部的刷新或分页时,无法手动调自定义的ajax方法,导致因数据格式错误,无法重新对datagrid重新绑定数据
作者: felt    时间: 2018-11-27 11:30:33

直接用url加载,表格上设置
totalField="totalCount"
dataField="list"
作者: buyiyanqi    时间: 2018-11-28 10:00:59

由于服务端返回的json中,实际数据是在data的子节点中,我通过设置totalField="data.totalCount",dataField="data.list"便可以成功展现数据,但是我当在使用combox控件时,采用valueField="data.id" textField="data.alias" 方式设置,发现无法绑定数据,想请教一下,有什么解决办法么。我combox控件获取到的json数据格式如下:
{
"appSeqNo": "",
"data": [
{
"id": "7",
"status": 1,
"createTime": "2018-11-27 18:55:55",
"updateTime": null,
"sort": null,
"remark": null,
"alias": "lemur-gen",
"author": "lihangyu",
"userId": 0,
"codePackage": "cn.afterturn.gen.modular.code",
"xmlPackage": "MET-INF.mapping",
"jsPackage": "static.modular.code",
"htmlPackage": "WEB-INF.view.modular.code",
"localPath": "D:\\mySpace\\lemur\\lemur-generation\\gen-admin\\src\\main",
"copyright": null,
"encoded": "UTF-8"
},
{
"id": "8",
"status": 1,
"createTime": "2018-11-27 18:55:55",
"updateTime": null,
"sort": null,
"remark": null,
"alias": "review-rest",
"author": "JueYue",
"userId": 1,
"codePackage": "cn.allisone.review.rest.modular.review",
"xmlPackage": "",
"jsPackage": "",
"htmlPackage": "",
"localPath": "",
"copyright": null,
"encoded": "UTF-8"
}
],
"gencode": "SUCCEED",
"serSeqNo": "",
"appId": "",
"sign": "",
"message": "操作成功",
"isSucceed": true,
"timestamp": "1543369562563"
}
作者: buyiyanqi    时间: 2018-11-28 10:29:09

felt 发表于 2018-11-27 11:30
直接用url加载,表格上设置
totalField="totalCount"
dataField="list"

由于服务端返回的json中,实际数据是在data的子节点中,我通过设置totalField="data.totalCount",dataField="data.list"便可以成功展现数据,但是我当在使用combox控件时,采用valueField="data.id" textField="data.alias" 方式设置,发现无法绑定数据,想请教一下,有什么解决办法么。我combox控件获取到的json数据格式如下:
{
"appSeqNo": "",
"data": [
{
"id": "7",
"status": 1,
"createTime": "2018-11-27 18:55:55",
"updateTime": null,
"sort": null,
"remark": null,
"alias": "lemur-gen",
"author": "lihangyu",
"userId": 0,
"codePackage": "cn.afterturn.gen.modular.code",
"xmlPackage": "MET-INF.mapping",
"jsPackage": "static.modular.code",
"htmlPackage": "WEB-INF.view.modular.code",
"localPath": "D:\\mySpace\\lemur\\lemur-generation\\gen-admin\\src\\main",
"copyright": null,
"encoded": "UTF-8"
},
{
"id": "8",
"status": 1,
"createTime": "2018-11-27 18:55:55",
"updateTime": null,
"sort": null,
"remark": null,
"alias": "review-rest",
"author": "JueYue",
"userId": 1,
"codePackage": "cn.allisone.review.rest.modular.review",
"xmlPackage": "",
"jsPackage": "",
"htmlPackage": "",
"localPath": "",
"copyright": null,
"encoded": "UTF-8"
}
],
"gencode": "SUCCEED",
"serSeqNo": "",
"appId": "",
"sign": "",
"message": "操作成功",
"isSucceed": true,
"timestamp": "1543369562563"
}
作者: dforce    时间: 2018-11-28 10:29:22

buyiyanqi 发表于 2018-11-28 10:00
由于服务端返回的json中,实际数据是在data的子节点中,我通过设置totalField="data.totalCount",dataField ...

你写错了
dataField="data"  
textField="alias"
valueField="id"
作者: joyoes    时间: 2020-3-24 12:20:26

felt 发表于 2018-11-27 11:30
直接用url加载,表格上设置
totalField="totalCount"
dataField="list"

我在mini-treegrid中设置totalField和dataField都不管用嘛




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2