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

Data Binding

As of the Kendo UI R2 2019 release, you can use the HierarchicalDataSource for binding components to data.

Binding to Local Data

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

<div id="target">target</div>
<ul id="contextmenu"></ul>

<script>
$(document).ready(function() {
    $("#contextmenu").kendoContextMenu({
        target: "#target",
        dataSource: [
            {
                text: "Item 1",
                expanded: true,
                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 Menu and bind it to a remote HierarchicalDataSource.

<div id="target">target</div>
<ul id="contextmenu"></ul>

<script>
$(document).ready(function() {
    $("#contextmenu").kendoContextMenu({
        target: "#target",
        dataTextField: "FullName",
        dataSource: {
            transport: {
                read: {
                    url: "https://demos.telerik.com/kendo-ui/service/Employees",
                    dataType: "jsonp"
                }
            },
             schema: {
                model: {
                    id: "EmployeeId",
                    hasChildren: "HasEmployees"
                }
            }
        }
    })
});
</script>

See Also

In this article