0

全部,

我有一个从 web 服务返回的 JSON 对象。我正在使用 Stringify 方法将其转换为字符串对象。

当我尝试将它与我的 jqGrid 集成时(使用 datatype:'jsonstring', datastr:myJSONstringobject)。如果它很简单,我可以将 JSON 列与网格映射(即'index:customerName')

但如果它是一个嵌套的 JSON 值(即 'index:customer.customerAddress.street'),它不会被加载到网格中。

有人可以帮忙吗?

提前致谢!

4

2 回答 2

2

如果我理解您的问题正确,您应该使用jsonmap包含点(如jsonmap: customer.customerAddress.street)而不是index. 如果你使用datatype: 'jsonstring'你应该使用nameindex参数相同的值,不包含点、空格或任何其他元字符。jsonmap如果您定义与您的数据相对应的数据,您可能可以减少使用的需要jsonReader。因为您没有发布 JSON 数据的示例,所以我无法向您解释更多。

大多数情况下,您不需要使用 Web 服务datatype: 'jsonstring'。相反,使用datatype: 'json'一些额外的参数会更好。

于 2012-04-19T17:38:44.547 回答
1

如果您有嵌套的 JSON 并且您想显示它在其中一个子注释中的行数据,您只需使用,例如,如果您在“数据”节点中有“jqGrid”的数据:

        jsonReader: {
            root: "data.rows",
            page: "data.page",
            total: "data.total",
            records: "data.records"
        }

注意:这在 jqGrid 版本 4.4.4 上 100% 有效

于 2013-03-06T06:27:43.100 回答