【问题标题】:Kendo UI TreeListDatasource Remote Data On Demand Id is nullKendo UI TreeListDatasource Remote Data On Demand Id 为空
【发布时间】:2016-10-06 12:58:42
【问题描述】:

我正在使用 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" }
    ]
});

这就是来自服务器的数据对于根的样子:

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

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

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

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

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

我正在使用剑道 2016.3.914

【问题讨论】:

    标签: kendo-ui kendo-treelist


    【解决方案1】:

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

    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 },
    
                }
            }
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-12
      • 2017-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多