【问题标题】:How can I mapping nested Json to Kendo UI grid?如何将嵌套的 Json 映射到 Kendo UI 网格?
【发布时间】:2020-11-08 07:25:43
【问题描述】:

我使用 web api 发送数据以显示在 Kendo UI 网格中。我的 web api 返回一个嵌套的 json。 如下:

{
"SearchRequest": {
        "Term": null,
        "SortDirection": "Desc",
        "Total": 0,
        "PageIndex": 1,
        "PageSize": 10,
        "CurrentSort": null
    },
    "OperationalRisks": [
        {
            "LocationCode": 224.0,
            "RegisterDate": "1/01/01"
        },
        {
            "LocationCode": 211.0,
            "RegisterDate": "1/01/01"
        }
 ]
}

之后,我会尝试以如下方式显示数据:

columns: [
                    { field: "OperationalRisks.LocationCode", title: "#" },
                    { field: "OperationalRisks.RegisterDate", title: "#" }
                ]

还有:

schema: {
                    model: {
                        fields: {
                            "OperationalRisks.LocationCode": { type: "number" }, 
                            "OperationalRisks.RegisterDate": { type: "number" }
                        }
                    }
                }

但数据没有绑定到网格

【问题讨论】:

标签: javascript asp.net json kendo-ui kendo-grid


【解决方案1】:

我的问题很容易解决,我想与您分享 首先你应该定义:

var json_data;

然后:

$("#grid").kendoGrid{{
datasource:{
type:"json",
data:json_data.OperationalRisks,
.
.
.

columns: [
           { field: "LocationCode", title: "#" },
           { field: "RegisterDate", title: "#" }
         ],
.
.
.
schema: {
                    model: {
                        fields: {
                            "LocationCode": { type: "number" }, 
                            "RegisterDate": { type: "number" }
                        }
                    }
                }

【讨论】:

    猜你喜欢
    • 2013-06-18
    • 2013-07-15
    • 2020-03-19
    • 2021-07-06
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 2018-12-13
    • 1970-01-01
    相关资源
    最近更新 更多