New to Telerik UI for ASP.NET MVCStart 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.

  1. Declare the model you wish to use for the View.

    Razor
    @model IEnumerable<ModelBindingDemo.Models.Category>
  2. 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;
                        }));
            })
    )

See Also

In this article
Model BindingSee Also
Not finding the help you need?
Contact Support