简体   繁体   English

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

[英]Kendo treeList datasource - not getting bound with remote data

I have written a directive for treeList and binding data to it from remote service call.我已经为 treeList 编写了一个指令,并将数据从远程服务调用绑定到它。 Below is the code for TreeListDataSource in link method of directive:下面是指令链接方法中 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();

following is the TreeList directive definition:以下是 TreeList 指令定义:

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

When i see the data bound to scope.treeListOptions.dataSource.data(), there are many new properties added as shown below:当我看到绑定到 scope.treeListOptions.dataSource.data() 的数据时,添加了许多新属性,如下所示:

 // 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

Properties like parent: (), parentIdField: "parentId", _loaded: true, dirty: false, hasChildren: true are added by the TreeListDataSource. TreeListDataSource 添加了诸如parent: ()、parentIdField: "parentId"、_loaded: true、dirty: false、hasChildren: true 之类的属性。

Is this the correct format for data?这是正确的数据格式吗? because the the TreeList is displaying "No records to display" .因为 TreeList 正在显示"No records to display"

Can anyone help me fix this issue?谁能帮我解决这个问题?

UPDATED Here is the link for angular directive created for treeList: http://jsfiddle.net/yuqorcvL/15/更新这里是为 treeList 创建的角度指令的链接: http : //jsfiddle.net/yuqorcvL/15/

The directive is still not work.该指令仍然无效。 Any help will be appreciated.任何帮助将不胜感激。

Thanks.谢谢。

You should add a schema in scope.treeListOptions.dataSource您应该在scope.treeListOptions.dataSource添加schema

schema: {
                        model: {
                            id: "EmployeeID",
                            parentId: "ReportsTo",
                            fields: {
                                ReportsTo: { field: "ReportsTo",  nullable: true },
                                EmployeeID: { field: "EmployeeId", type: "number" },
                                Extension: { field: "Extension", type: "number" }
                            },
                            expanded: true
                        }
                    }

look that example at kendo docs看看kendo docs上的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM