[go: up one dir, main page]

New to Kendo UI for jQuery? Download free 30-day trial

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.

Do not use the names of the kendo.data.Node fields and methods (for example, children) as fields in the TreeView data.

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