带有点运算符的jquery jqgrid属性 [英] jquery jqgrid propery with dot operator
问题描述
我有一个带有点."的json.运算符. 当我尝试渲染网格时,它显示为空白(没有任何错误).
I have a json with a property having dot "." operator in it. When im trying to render my grid, it comes up as blank (without any errors).
这是我的JSON:
{
"total":1,
"page":1,
"records":2,
"rows":[{
"id":2110040,
"cell":{
"function.code":"dsadad",
"service.name":"dsadasda"
}
},
{
"id":2115040,
"cell":{
"function.code":"iuiyuiy",
"service.name":"iyuiyuiy"
}
}
]
}
这是我的colModel
this is my colModel
colModel : [ {
name : 'service.name',
search : 'true',
editable : true,
//index : 'service.name',
width : 200,
jsonmap : "cell.service.name"
},
{
name : 'function.code',
search : 'true',
editable : true,
sortable:true,
//index : 'function.code',
width : 200,
jsonmap : "cell.function.code"
}],
JSON阅读器是:
jsonReader : {
repeatitems : false,
root : "rows",
cell : "cell",
id : "id",
page : "page",
records : "records"
},
请帮忙,我在这里想念什么?
Please help,what am i missing here ??
谢谢!
推荐答案
我发现您的问题很有趣.它很接近在此处中描述的问题,但在JSON而不是XML的情况.
I find you question interesting. It's close to the problem described here, but in case of JSON instead of XML.
问题是jqGrid尝试读取关于obj.cell.function.code
而不是obj.cell['function.code']
的行.为了让jqGrid正确读取数据,您可以使用函数作为jsonmap
:
The problem is that jqGrid try to read rows with respect of obj.cell.function.code
instead of obj.cell['function.code']
. To let jqGrid to read the data correctly you can use functions as the jsonmap
:
colModel: [
{
name: 'service_name',
search: 'true',
editable: true,
width: 200,
jsonmap: function (obj) {
return obj.cell['service.name'];
}
},
{
name: 'function_code',
search: 'true',
editable: true,
sortable: true,
width: 200,
jsonmap: function (obj) {
return obj.cell['function.code'];
}
}
]
如何在
这篇关于带有点运算符的jquery jqgrid属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!