New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Data Binding
The ContextMenu provides Model Binding for binding it to data:
Model Binding
The Telerik UI ContextMenu enables you to bind it to a hierarchical model.
-
Declare the model you wish to use for the View.
Razor@model IEnumerable<ModelBindingDemo.Models.Category>
-
Add the ContextMenu.
Razor@model IEnumerable<ModelBindingDemo.Models.Category> <div id="target">Click to open</div> @(Html.Kendo().ContextMenu() .Name("contextmenu") .Target("#target") .ShowOn("click") .BindTo(Model, mappings => { mappings.For<ModelBindingDemo.Models.Category>(binding => binding .ItemDataBound((item, category) => { item.Text = category.CategoryName; }) .Children(category => category.Products)); mappings.For<ModelBindingDemo.Models.Product>(binding => binding .ItemDataBound((item, product) => { item.Text = product.ProductName; })); }) )