首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kendo treeList数据源-没有与远程数据绑定

Kendo treeList数据源-没有与远程数据绑定
EN

Stack Overflow用户
提问于 2015-09-25 08:20:54
回答 1查看 1.9K关注 0票数 2

我为treeList编写了一个指令,并通过远程服务调用将数据绑定到它。下面是TreeListDataSource在指令的链接方法中的代码:

代码语言:javascript
复制
scope.treeListOptions.dataSource = new kendo.data.TreeListDataSource({
  transport: {
    read: function(options) {
      scope.getData().then(function(dataToBeDisplayed) {
        options.success(dataToBeDisplayed);
      }, function(error) {
        $log.error(error);
      });
    },
    error: function(e) {
      alert(e.status + e.errorThrown);
    },
  },
});

scope.treeListOptions.dataSource.read(); 

以下是TreeList指令的定义:

代码语言:javascript
复制
var TreeListDirectiveDefinition = {
  restrict: 'E',
  replace: true,
  template: '<div><kendo-treelist k-options="treeListOptions"></kendo-treelist></div>',
  scope: {
    columns: '=',
    getMethod: '&'
  },
  link: linkTreeList
};

当我看到绑定到scope.treeListOptions.dataSource.data()的数据时,添加了许多新属性,如下所示:

代码语言:javascript
复制
// parent element
C.define.init
PartExamined: "test"
StudyUid: "1.3.6.1.4.1.30071.8.56809868014.4964677242993979.234.56616"
_events: Object
_loaded: true
dirty: false
hasChildren: true
id: 1
parent: ()
parentId: null
parentIdField: "parentId"
uid: "1ca6302c-b1ad-493f-b002-d2032a548a80"
__proto__: i.extend.i


//child element
C.define.init
PartExamined: "test2"
SeriesInstanceUid: "1.3.6.1.4.1.30071.8.56809868014.4964677242993979.234.56617"
_events: Object
_loaded: true
dirty: false
hasChildren: false
id: 2
parent: ()
parentId: 1
parentIdField: "parentId"
uid: "953bc7a7-e5e8-4f26-a120-b13402c6cce4"
__proto__: i.extend.i

属性如父级:()、parentIdField:"parentId“、_loaded: true、脏: false、hasChildren: true都是由TreeListDataSource添加的。

这是正确的数据格式吗?因为TreeList正在显示“没有要显示的记录”

有人能帮我解决这个问题吗?

更新的这里是为treeList:http://jsfiddle.net/yuqorcvL/15/创建的角指令的链接

指令仍然不起作用。任何帮助都将不胜感激。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-09-29 09:38:32

您应该在schema中添加一个scope.treeListOptions.dataSource

代码语言:javascript
复制
schema: {
                        model: {
                            id: "EmployeeID",
                            parentId: "ReportsTo",
                            fields: {
                                ReportsTo: { field: "ReportsTo",  nullable: true },
                                EmployeeID: { field: "EmployeeId", type: "number" },
                                Extension: { field: "Extension", type: "number" }
                            },
                            expanded: true
                        }
                    }

那个例子在剑道上的文档

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32777830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档