Kendo UI TreeListDatasource远程数据按需Id为空

时间:2016-10-06 12:58:43

标签: kendo-ui kendo-treelist

我正在使用Kendo TreeList组件并尝试按需远程数据。这就是数据源的样子:

 dsLocations = new kendo.data.TreeListDataSource({
    transport: {
        read: {
            url: baseUrl + "getsuggestedorganizationlocations?oid=" + $("#Id").val(),
            dataType: "json"
        },

        schema: {
            model: {
                id: "Id",
                parentId: "ParentId",
                fields: {
                    Id: { type: "number", nullable: false },
                    ParentId: { field: "ParentId", nullable: true }
                }
            }
        }
    }
});

这是TreeList组件的配置方式:

$("#suggestedLocations").kendoTreeList({
    dataSource: dsLocations,
    columns: [
        { field: "Name", expandable: true, title: "Location", width: 250 },
        { field: "Selected", title: "Selected" }
    ]
});

这就是来自服务器的数据对于root来说是什么样的:

[{"Id":5,"ParentId":null,"Selected":true,"hasChildren":true,"Name":"Kitchen"}]

当我展开节点以检索子节点时,传递给服务器的查询字符串中的“id”为空。

Empty id

如果我将来自服务器的模型更改为:

[{"id":5,"parentId":null,"Selected":true,"hasChildren":true,Name":"Kitchen"}]

如果id和parentId是小写的,它可以工作。我的理解是架构配置假设要映射它。什么,我错过了?

我正在使用Kendo 2016.3.914

1 个答案:

答案 0 :(得分:0)

找到它。我已将架构设置放在传输配置中。这应该是:

dsLocations = new kendo.data.TreeListDataSource({
    transport: {
        read: {
            url: _organizeApp.baseUrl + "getsuggestedorganizationlocations?oid=" + $("#Id").val(),
            dataType: "json"
        }

    },
    schema: {
        model: {
            id: "Id",
            parentId: "ParentId",
            fields: {
                Id: { field: "Id", type: "number", nullable: false },
                ParentId: { field: "ParentId", nullable: true },

            }
        }
    }
});