且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 JSON 子数组绑定到 Kendo 网格

更新时间:2022-06-04 02:45:15

在响应中,您已将 container 定义为 array 但不确定它是否可能重复.据我了解,实际数据是items.正确的?如果是,这是最小的 DataSource 定义.

In the response, you have defined container as an array but not sure if it might repeat. As far as I understand the actual data is items. Correct? If so, this is the minimum DataSource definition.

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url     : "http://...",
            dataType: "json",
            data: {
                Accept: "application/json"
            }
        }
    },
    pageSize : 10,
    schema   : {
        data: "container[0].items"
    }
});

注意:您显示的响应看起来不像 JSONP,而是 JSON.这就是我将 dataType 设置为 JSON 的原因.

NOTE: The response that you show doesn't look like a JSONP but a JSON. That's why I'm setting dataType as JSON.