带有点运算符的jquery jqgrid属性 [英] jquery jqgrid propery with dot operator

查看:52
本文介绍了带有点运算符的jquery jqgrid属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有点."的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆