Kendo Treeview

Kendo Treeview with Hierachical Data-Source

by ruapho

HTML

<script src="http://cdn.kendostatic.com/2013.1.319/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.default.min.css">
<div id="navigation-treeview"></div>

JavaScript

$(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 } );
});