Nested DataSources and TreeView with kendo ui

北城以北 提交于 2019-12-23 01:58:27

问题


I am having trouble with the Hierarchical Data Source in conjunction with the TreeView and nesting. The goal is to show a treeview with root items like "employees", "profiles" and sub items being the acutal items. So every root item is using a different data source. This is not working, as the root nodes are not expanding while the data source seems to load perfectly. Here's the code:

$(document).ready(function() {
var userProfileDataSource  = new kendo.data.HierarchicalDataSource( {
            transport: {
                read: function (options) {
                    var items = [
                        {
                            text: "userprofile 1",
                            hasChildren: false
                        },
                        {
                            text: "userprofile 2",
                            hasChildren: false
                        }
                    ];
                    options.success(items);
                }
            }
        }),
    categories = new kendo.data.HierarchicalDataSource({
            transport: {
                read: function(options) {
                    options.success([
                        {
                            text: "Employees",
                            hasChildren: false
                        },
                        {
                            text: "UserProfiles",
                            children: userProfileDataSource,
                            hasChildren: true
                        }
                    ]);
                }
            }
        });

   $("#navigation-treeview").kendoTreeView( { dataSource: categories } );
});

JSFiddle

Any ideas?

来源:https://stackoverflow.com/questions/16016983/nested-datasources-and-treeview-with-kendo-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!