Local and Remote Data Binding

The TreeView provides options for binding it to local data arrays or remote data services.

For more information on binding the TreeView to different service end-points, refer to the HierarchicalDataSource documentation.

Binding to Local Data

The following example demonstrates how to create a TreeView and bind it to a local data source.

<div id="treeView"></div>

<script>
$(document).ready(function() {
    $("#treeView").kendoTreeView({
        dataSource: [
            {
                text: "Item 1",
                items: [
                    { text: "Item 1.1" },
                    { text: "Item 1.2" }
                ]
            },
            { text: "Item 2" }
        ]
    })
});
</script>

Binding to Remote Data

The following example demonstrates how to create a TreeView and bind it to a remote HierarchicalDataSource.

$("#treeView").kendoTreeView({
    dataSource: {
        transport: {
            read: {
                url: "https://demos.telerik.com/kendo-ui/service/Employees",
                dataType: "json"
            }
        },
        schema: {
            model: {
                id: "EmployeeId",
                hasChildren: "HasEmployees"
            }
        }
    }
})

See Also

In this article
Not finding the help you need? Improve this article