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

MenuBuilder

Properties

WriteAction - Func

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)))
            )

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");
                        })
            )

Direction(System.String)

Specifies Menu opening direction.

Parameters

value - System.String

The desired direction.

Example


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

Direction(Kendo.Mvc.UI.MenuDirection)

Specifies Menu opening direction.

Parameters

value - MenuDirection

The desired direction.

Example


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

DataSource(System.Action)

Configure the DataSource of the component

Parameters

configurator - System.Action<HierarchicalDataSourceBuilder>

The action that configures the Kendo.Mvc.UI.Fluent.MenuBuilder.DataSource(System.Action{Kendo.Mvc.UI.Fluent.HierarchicalDataSourceBuilder{System.Object}}).

Example


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

DataSource(System.String)

Set ID of the DataSource that to be used for data binding

Parameters

dataSourceId - System.String

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)
            )

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);
                        })
            )

CloseOnClick(System.Boolean)

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

Parameters

value - System.Boolean

The value for CloseOnClick

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

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

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

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

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

HoverDelay(System.Double)

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

Parameters

value - System.Double

The value for HoverDelay

OpenOnClick(System.Action)

Specifies that the root sub menus will be opened on item click.

Parameters

configurator - System.Action<MenuOpenOnClickSettingsBuilder>

The configurator for the openonclick setting.

OpenOnClick()

Specifies that the root sub menus will be opened on item click.

OpenOnClick(System.Boolean)

Specifies that the root sub menus will be opened on item click.

Parameters

enabled - System.Boolean

Enables or disables the openonclick option.

Scrollable(System.Action)

If enabled, the Menu displays buttons that scroll the items when they cannot fit the width or the popups' height of the Menu. By default, scrolling is disabled.The following example demonstrates how to enable the scrolling functionality.

Parameters

configurator - System.Action<MenuScrollableSettingsBuilder>

The configurator for the scrollable setting.

Scrollable()

If enabled, the Menu displays buttons that scroll the items when they cannot fit the width or the popups' height of the Menu. By default, scrolling is disabled.The following example demonstrates how to enable the scrolling functionality.

Scrollable(System.Boolean)

If enabled, the Menu displays buttons that scroll the items when they cannot fit the width or the popups' height of the Menu. By default, scrolling is disabled.The following example demonstrates how to enable the scrolling functionality.

Parameters

enabled - System.Boolean

Enables or disables the scrollable option.

Orientation(Kendo.Mvc.UI.MenuOrientation)

Specifies the orientation in which the menu items will be ordered

Parameters

value - MenuOrientation

The value for Orientation

Events(System.Action)

Configures the client-side events.

Parameters

configurator - System.Action<MenuEventBuilder>

The client events action.

Example


            @(Html.Kendo().Menu()
                  .Name("Menu")
                  .Events(events => events
                      .Close("onClose")
                  )
            )

ToComponent()

Returns the internal view component.

Expression(System.String)

Sets the name of the component.

Parameters

modelExpression - System.String

Explorer(Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer)

Sets the name of the component.

Parameters

modelExplorer - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer

Name(System.String)

Sets the name of the component.

Parameters

componentName - System.String

The name.

Deferred(System.Boolean)

Suppress initialization script rendering. Note that this options should be used in conjunction with

Parameters

deferred - System.Boolean

HtmlAttributes(System.Object)

Sets the HTML attributes.

Parameters

attributes - System.Object

The HTML attributes.

HtmlAttributes(System.Collections.Generic.IDictionary)

Sets the HTML attributes.

Parameters

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

The HTML attributes.

ScriptAttributes(System.Object,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

attributes - System.Object

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

ScriptAttributes(System.Collections.Generic.IDictionary,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

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

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

Render()

Renders the component in place.

ToHtmlString()

WriteTo(System.IO.TextWriter,System.Text.Encodings.Web.HtmlEncoder)

Parameters

writer - System.IO.TextWriter
encoder - System.Text.Encodings.Web.HtmlEncoder

ToClientTemplate()

AsModule(System.Boolean)

Specifies whether the initialization script of the component will be rendered as a JavaScript module.

Parameters

value - System.Boolean
In this article
Not finding the help you need?