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

Defines the fluent API for configuring the Kendo UI Menu

Definition

Constructors

Initializes a new instance of the MenuBuilder class.

C#
public MenuBuilder(Menu component)
Parameters:componentMenu

Methods

Sets the menu animation options.

C#
public MenuBuilder Animation(Action<PopupAnimationBuilder> animationAction)
Parameters:animationActionAction<PopupAnimationBuilder>

The animation settings.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Animation(a =&gt; a.Open(o =&gt; o.Expand(ExpandDirection.Vertical)))
)

Disables the menu animation.

C#
public MenuBuilder Animation(bool enable)
Parameters:enablebool

Boolean parameter.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Animation(false)
)

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

C#
public MenuBuilder BindTo(IEnumerable dataSource, Action<NavigationBindingFactory<MenuItem>> factoryAction)
Parameters:dataSourceIEnumerable

The data source.

factoryActionAction<NavigationBindingFactory<MenuItem>>

The action which will configure the mappings

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

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

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 Items(Action<MenuItemFactory>) method.

C#
public MenuBuilder BindTo(IEnumerable<MenuItem> items)
Parameters:itemsIEnumerable<MenuItem>

The list of items

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("TreeView")
.BindTo(model)
)

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.

C#
public MenuBuilder BindTo<T>(IEnumerable<T> dataSource, Action<MenuItem, T> itemDataBound)
Parameters:dataSourceIEnumerable<T>

The data source.

itemDataBoundAction<MenuItem, T>

The action executed for every data bound item.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.BindTo(new []{"First", "Second"}, (item, value) =&gt;
{
item.Text = value;
})
)

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

C#
public MenuBuilder CloseOnClick(bool value)
Parameters:valuebool

The value for CloseOnClick

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.CloseOnClick(false)
)

Sets the field of the data item that provides the trailing actions-region content of the menu items, rendered as a k-menu-link-actions span positioned before the item's expand/collapse arrow. This is useful for displaying supplementary information next to a menu item's label, such as a keyboard-shortcut hint (for example, Ctrl+N). If not set, the Menu falls back to using the actions field of the data item. The actions content is rendered as raw, unencoded HTML, so make sure that any value supplied through dataActionsField (or through the item's actions field) is trusted in the same way as content supplied through dataContentField.

C#
public MenuBuilder DataActionsField(string value)
Parameters:valuestring

The value for DataActionsField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

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

C#
public MenuBuilder DataContentField(string value)
Parameters:valuestring

The value for DataContentField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataContentField("Value")
)

Sets the field of the data item that provides the secondary description line of the menu items, rendered as a k-menu-link-description span displayed beneath the item's label. This is useful for showing additional context about a menu item, such as a short explanatory note under its title. If not set, the Menu falls back to using the description field of the data item. The description content is HTML-encoded by default, consistent with the item's text, and this can be disabled per item by setting encoded: false on the data item.

C#
public MenuBuilder DataDescriptionField(string value)
Parameters:valuestring

The value for DataDescriptionField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

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

C#
public MenuBuilder DataIconClassField(string value)
Parameters:valuestring

The value for DataIconClassField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataIconClassField("Value")
)

Sets the field of the data item that provides the icon name of the menu items.The field can also hold an icon descriptor such as { name: "gear", variant: "outline" }. The variant can be outline, solid, or duotone; it applies to SVG rendering and is ignored for font icons.

C#
public MenuBuilder DataIconField(string value)
Parameters:valuestring

The value for DataIconField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataIconField("Value")
)

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

C#
public MenuBuilder DataImageUrlField(string value)
Parameters:valuestring

The value for DataImageUrlField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataImageUrlField("Value")
)

Configure the DataSource of the component

C#
public MenuBuilder DataSource(Action<HierarchicalDataSourceBuilder<object>> configurator)
Parameters:configuratorAction<HierarchicalDataSourceBuilder<object>>

The HierarchicalDataSourceBuilder<TModel> that configures the DataSource of the component.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataSource(dataSource =&gt; dataSource
.Read(read =&gt; read
.Action("Employees", "PanelBar")
)
)
)

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

C#
public MenuBuilder DataSource(string dataSourceId)
Parameters:dataSourceIdstringReturns:

MenuBuilder

Returns the current MenuBuilder instance.

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

C#
public MenuBuilder DataSpriteCssClassField(string value)
Parameters:valuestring

The value for DataSpriteCssClassField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataSpriteCssClassField("Value")
)

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

C#
public MenuBuilder DataTextField(string value)
Parameters:valuestring

The value for DataTextField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataTextField("Value")
)

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

C#
public MenuBuilder DataUrlField(string value)
Parameters:valuestring

The value for DataUrlField

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.DataUrlField("Value")
)

Specifies Menu opening direction.

C#
public MenuBuilder Direction(MenuDirection value)
Parameters:valueMenuDirection

The desired direction.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Direction(MenuDirection.Left)
)

Specifies Menu opening direction.

C#
public MenuBuilder Direction(string value)
Parameters:valuestring

The desired direction.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Direction("top")
)

Configures the client-side events.

C#
public MenuBuilder Events(Action<MenuEventBuilder> configurator)
Parameters:configuratorAction<MenuEventBuilder>

The client events action.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@(Html.Kendo().Menu()
.Name("Menu")
.Events(events =&gt; events
.Close("onClose")
)
)

Select item depending on the current URL.

C#
public MenuBuilder HighlightPath(bool value)
Parameters:valuebool

If true the item will be highlighted.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.HighlightPath(true)
)

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

C#
public MenuBuilder HoverDelay(double value)
Parameters:valuedouble

The value for HoverDelay

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.HoverDelay(300)
)

Specifies the position of the icon in the Menu items using the text content as a reference.

C#
public MenuBuilder IconPosition(IconPosition value)
Parameters:valueIconPosition

The value for IconPosition

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.IconPosition(IconPosition.After)
)

Callback for each item.

C#
public MenuBuilder ItemAction(Action<MenuItem> action)
Parameters:actionAction<MenuItem>

Action, which will be executed for each item.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.ItemAction(item =&gt;
{
item
.Text(...)
.HtmlAttributes(...);
})
)

Defines the items in the menu

C#
public MenuBuilder Items(Action<MenuItemFactory> addAction)
Parameters:addActionAction<MenuItemFactory>

The add action.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt;
{
items.Add().Text("First Item");
items.Add().Text("Second Item");
})
)

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

C#
public MenuBuilder OpenOnClick()
Returns:

MenuBuilder

Returns the current instance of MenuOpenOnClickSettingsBuilder .

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

C#
public MenuBuilder OpenOnClick(Action<MenuOpenOnClickSettingsBuilder> configurator)
Parameters:configuratorAction<MenuOpenOnClickSettingsBuilder>

The MenuOpenOnClickSettingsBuilder for the openonclick setting.

Returns:

MenuBuilder

Returns the current instance of MenuBuilder .

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

C#
public MenuBuilder OpenOnClick(bool enabled)
Parameters:enabledbool

Enables or disables the openonclick option.

Returns:

MenuBuilder

Returns the current instance of MenuOpenOnClickSettingsBuilder .

Specifies the orientation in which the menu items will be ordered.

C#
public MenuBuilder Orientation(MenuOrientation value)
Parameters:valueMenuOrientation

The value for Orientation

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Orientation(MenuOrientation.Vertical)
)

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.

C#
public MenuBuilder Scrollable()
Returns:

MenuBuilder

Returns the current instance of MenuScrollableSettingsBuilder .

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.

C#
public MenuBuilder Scrollable(Action<MenuScrollableSettingsBuilder> configurator)
Parameters:configuratorAction<MenuScrollableSettingsBuilder>

The MenuScrollableSettingsBuilder for the scrollable setting.

Returns:

MenuBuilder

Returns the current instance of MenuBuilder .

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.

C#
public MenuBuilder Scrollable(bool enabled)
Parameters:enabledbool

Enables or disables the scrollable option.

Returns:

MenuBuilder

Returns the current instance of MenuScrollableSettingsBuilder .

Defines the security trimming functionality of the component

C#
public MenuBuilder SecurityTrimming(Action<SecurityTrimmingBuilder> securityTrimmingAction)
Parameters:securityTrimmingActionAction<SecurityTrimmingBuilder>

The securityTrimming action.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.SecurityTrimming(builder =&gt;
{
builder.Enabled(true).HideParent(true);
})
)

Enable/disable security trimming functionality of the component.

C#
public MenuBuilder SecurityTrimming(bool value)
Parameters:valuebool

If true security trimming is enabled.

Returns:

MenuBuilder

Returns the current MenuBuilder instance.

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.SecurityTrimming(false)
)

Sets the size of the component.

C#
public MenuBuilder Size(ComponentSize value)
Parameters:valueComponentSize

The value for Size

Returns:

MenuBuilder

Returns the current MenuBuilder instance.