Kendo treeList数据源 - 未与远程数据绑定

时间:2015-09-25 08:20:55

标签: angularjs kendo-ui kendo-grid kendo-treeview

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



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指令定义:



var TreeListDirectiveDefinition = {
  restrict: 'E',
  replace: true,
  template: '<div><kendo-treelist k-options="treeListOptions"></kendo-treelist></div>',
  scope: {
    columns: '=',
    getMethod: '&'
  },
  link: linkTreeList
};
&#13;
&#13;
&#13;

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

&#13;
&#13;
// 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
&#13;
&#13;
&#13;

TreeListDataSource添加了 parent :(),parentIdField:&#34; parentId&#34;,_loaded:true,dirty:false,hasChildren:true 等属性。

这是正确的数据格式吗?因为TreeList显示&#34;没有要显示的记录&#34;

任何人都可以帮我解决这个问题吗?

已更新 以下是为treeList创建的angular指令的链接:http://jsfiddle.net/yuqorcvL/15/

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

感谢。

1 个答案:

答案 0 :(得分:2)

您应该在schema

中添加scope.treeListOptions.dataSource
schema: {
                        model: {
                            id: "EmployeeID",
                            parentId: "ReportsTo",
                            fields: {
                                ReportsTo: { field: "ReportsTo",  nullable: true },
                                EmployeeID: { field: "EmployeeId", type: "number" },
                                Extension: { field: "Extension", type: "number" }
                            },
                            expanded: true
                        }
                    }

在kendo docs上查看that example