New to Telerik UI for ASP.NET MVC? Download free 30-day trial

MenuBuilder

Methods

Animation(System.Boolean)

Disables the menu animation.

Parameters

enable - System.Boolean

Boolean parameter.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Animation(false)
            )

Animation(System.Action)

Sets the menu animation options.

Parameters

animationAction - System.Action<PopupAnimationBuilder>

The animation settings.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Animation(a => a.Open(o => o.Expand(ExpandDirection.Vertical)))
            )

PopupCollision(System.Boolean)

Disables the menu popup collision detection.

Parameters

enable - System.Boolean

Boolean parameter.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .PopupCollision(false)
            )

PopupCollision(System.Action)

Sets the menu popup collision detection.

Parameters

popupCollisionAction - System.Action<PopupCollisionBuilder>

The collision action. Can be "fit", "flip" or "fit flip".

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .PopupCollision(c => c.Collision("flip"))
            )

Items(System.Action)

Defines the items in the menu

Parameters

addAction - System.Action<MenuItemFactory>

The add action.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Items(items =>
                        {
                            items.Add().Text("First Item");
                            items.Add().Text("Second Item");
                        })
            )

Events(System.Action)

Configures the client-side events.

Parameters

clientEventsAction - System.Action<MenuEventBuilder>

The client events action.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Events(events =>
                            events.Open("onOpen").OnClose("onClose")
                        )
            )

Direction(Kendo.Mvc.UI.MenuDirection)

Specifies Menu opening direction.

Parameters

value - MenuDirection

The desired direction.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Direction(MenuDirection.Left)
            )

Direction(System.String)

Specifies Menu opening direction.

Parameters

value - System.String

The desired direction.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Direction("top")
            )

Orientation(Kendo.Mvc.UI.MenuOrientation)

Sets the menu orientation.

Parameters

value - MenuOrientation

The desired orientation.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Orientation(MenuOrientation.Vertical)
            )

OpenOnClick(System.Boolean)

Enables or disables the "open-on-click" feature.

Parameters

value - System.Boolean

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .OpenOnClick(true)
            )

OpenOnClick(System.Action)

If RootMenuItems setting is enabled - all root menus will be opened on click. Respectively, if SubMenuItems is enabled - all sub menus will be opened on click.

Parameters

openOnClickAction - System.Action<MenuOpenOnClickBuilder>

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .OpenOnClick(o => o.RootMenuItems(true).SubMenuItems(true))
            )

CloseOnClick(System.Boolean)

Specifies that sub menus should close after item selection (provided they won't navigate).

Parameters

value - System.Boolean

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .CloseOnClick(false)
            )

HoverDelay(System.Int32)

Specifies the delay in ms before the menu is opened/closed - used to avoid accidental closure on leaving.

Parameters

value - System.Int32

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .HoverDelay(300)
            )

BindTo(System.String,System.Action)

Binds the menu to a sitemap

Parameters

viewDataKey - System.String

The view data key.

siteMapAction - System.Action<MenuItem,SiteMapNode>

The action to configure the item.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .BindTo("examples", (item, siteMapNode) =>
                        {
                        })
            )

BindTo(System.String)

Binds the menu to a sitemap.

Parameters

viewDataKey - System.String

The view data key.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .BindTo("examples")
            )

BindTo(System.Collections.Generic.IEnumerable,System.Action)

Binds the menu to a list of objects. The menu will be "flat" which means a menu item will be created for every item in the data source.

Parameters

dataSource - System.Collections.Generic.IEnumerable<T>

The data source.

itemDataBound - System.Action<MenuItem,T>

The action executed for every data bound item.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .BindTo(new []{"First", "Second"}, (item, value) =>
                        {
                           item.Text = value;
                        })
            )

BindTo(System.Collections.IEnumerable,System.Action)

Binds the menu to a list of objects. The menu will create a hierarchy of items using the specified mappings.

Parameters

dataSource - System.Collections.IEnumerable

The data source.

factoryAction - System.Action<NavigationBindingFactory>

The action which will configure the mappings

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .BindTo(Model, mapping => mapping
                                .For<Customer>(binding => binding
                                    .Children(c => c.Orders) // The "child" items will be bound to the the "Orders" property
                                    .ItemDataBound((item, c) => item.Text = c.ContactName) // Map "Customer" properties to MenuItem properties
                                )
                                .For<Order<(binding => binding
                                    .Children(o => null) // "Orders" do not have child objects so return "null"
                                    .ItemDataBound((item, o) => item.Text = o.OrderID.ToString()) // Map "Order" properties to MenuItem properties
                                )
                        )
            )

BindTo(System.Collections.Generic.IEnumerable)

Binds the menu to a list of items. Use if the menu items are being sent from the controller. To bind the Menu declaratively, use the method.

Parameters

items - System.Collections.Generic.IEnumerable<MenuItem>

The list of items

Example


             @( Html.Kendo().Menu()
                        .Name("TreeView")
                        .BindTo(model)
            )

DataSource(System.Action)

Configure the DataSource of the component

Parameters

configurator - System.Action<HierarchicalDataSourceBuilder>

The action that configures the DataSource.

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataSource(dataSource => dataSource
                    .Read(read => read
                        .Action("Employees", "PanelBar")
                    )
                )
             )

DataSource(System.String)

Sets the DataSource ID of the component

Parameters

dataSourceId - System.String

Configures the DataSource ID.

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataSource("dataSourceId")
             )

DataTextField(System.String)

Sets the field of the data item that provides the text of the menu items.

Parameters

value - System.String

The value for DataTextField

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataTextField("Value")
             )

DataUrlField(System.String)

Sets the field of the data item that provides the url of the menu items.

Parameters

value - System.String

The value for DataUrlField

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataUrlField("Value")
             )

DataSpriteCssClassField(System.String)

Sets the field of the data item that provides the sprite css class of the menu items.

Parameters

value - System.String

The value for DataSpriteCssClassField

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataSpriteCssClassField("Value")
             )

DataImageUrlField(System.String)

Sets the field of the data item that provides the image url of the menu items.

Parameters

value - System.String

The value for DataImageUrlField

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataImageUrlField("Value")
             )

DataContentField(System.String)

Sets the field of the data item that provides the content of the menu items.

Parameters

value - System.String

The value for DataContentField

Example


             @( Html.Kendo().Menu()
                .Name("Menu")
                .DataContentField("Value")
             )

ItemAction(System.Action)

Callback for each item.

Parameters

action - System.Action<MenuItem>

Action, which will be executed for each item.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .ItemAction(item =>
                        {
                            item
                                .Text(...)
                                .HtmlAttributes(...);
                        })
            )

HighlightPath(System.Boolean)

Select item depending on the current URL.

Parameters

value - System.Boolean

If true the item will be highlighted.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .HighlightPath(true)
            )

SecurityTrimming(System.Boolean)

Enable/disable security trimming functionality of the component.

Parameters

value - System.Boolean

If true security trimming is enabled.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .SecurityTrimming(false)
            )

SecurityTrimming(System.Action)

Defines the security trimming functionality of the component

Parameters

securityTrimmingAction - System.Action<SecurityTrimmingBuilder>

The securityTrimming action.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .SecurityTrimming(builder =>
                        {
                            builder.Enabled(true).HideParent(true);
                        })
            )

Scrollable(System.Action)

If enabled, the Menu will display buttons that will scroll the menu items, when they cannot fit the Menu width or menu popups height. By default scrolling is disabled.

Parameters

scrollableAction - System.Action<MenuScrollableBuilder>

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Scrollable(s => s.Distance(300))
            )

Scrollable(System.Boolean)

If enabled, the Menu will display buttons that will scroll the menu items, when they cannot fit the Menu width or menu popups height. By default scrolling is disabled.

Parameters

enabled - System.Boolean

Boolean flag.

Example


             @( Html.Kendo().Menu()
                        .Name("Menu")
                        .Scrollable(true)
            )

ToComponent()

Returns the internal view component.

Name(System.String)

Sets the name of the component.

Parameters

componentName - System.String

The name of the component.

Example


            @(Html.Kendo().Grid<OrderViewModel>()
               .Name("grid")
               .Columns(columns =>
               {
                   columns.Bound(p => p.OrderID).Filterable(false);
                   columns.Bound(p => p.Freight);  
               })
               .DataSource(dataSource => dataSource
                   .Ajax()
                   .PageSize(20)
                   .Read(read => read.Action("Orders_Read", "Grid"))
               )
            )

Deferred(System.Boolean)

Suppress initialization script rendering. Note that this options should be used in conjunction with Kendo.Mvc.UI.Fluent.WidgetFactory.DeferredScripts(System.Boolean)

Parameters

deferred - System.Boolean

ModelMetadata(System.Web.Mvc.ModelMetadata)

Uses the Metadata of the Model.

Parameters

modelMetadata - System.Web.Mvc.ModelMetadata

The metadata set for the Model

HtmlAttributes(System.Object)

Sets the HTML attributes.

Parameters

attributes - System.Object

The HTML attributes.

HtmlAttributes(System.Collections.Generic.IDictionary)

Parameters

attributes - System.Collections.Generic.IDictionary<String,Object>

AsChildComponent()

Render()

Renders the component.

Example


            @(@Page Inherits="System.Web.Mvc.ViewPage<IEnumerable<Product>>" )
            @( Html.Kendo().Grid(Model)
                .Name("grid")
                .DetailTemplate(product => {
                    )
                       Product Details:
                       <div>Product Name: @( product.ProductName )</div>
                       <div>Units In Stock: @( product.UnitsInStock )</div>
                    @(
                })
                .Render();
            )

ToHtmlString()

ToClientTemplate()

In this article
Not finding the help you need?