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

ContextMenuBuilder

Properties

WriteAction - Func

Methods

Animation(System.Boolean)

Parameters

enable - System.Boolean

Animation(System.Action)

Sets the Animation options.

Parameters

animationAction - System.Action<PopupAnimationBuilder>

The animation settings.

Example


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

OpenOnClick(System.Boolean)

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

Parameters

value - System.Boolean

Boolean parameter.

Example


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

DataSource(System.Action)

Configure the DataSource of the component

Parameters

configurator - System.Action<HierarchicalDataSourceBuilder>

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

Example


             @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataSource(dataSource => dataSource
                    .Read(read => read
                        .Action("GetData", "Home")
                    )
                )
             )

DataSource(System.String)

Sets the ID of the DataSource to be used for data binding

Parameters

dataSourceId - System.String

Configures the DataSource ID.

Example


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

Items(System.Action)

Defines the items in the menu

Parameters

addAction - System.Action<ContextMenuItemFactory>

The add action.

Example


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

Direction(System.String)

Specifies ContextMenu opening direction.

Parameters

value - System.String

The desired direction.

Example


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

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<ContextMenuItem,T>

The action executed for every data bound item.

Example


             @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .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().ContextMenu()
                        .Name("ContextMenu")
                        .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 ContextMenuItem 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 ContextMenuItem 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 ContextMenu declaratively, use the method.

Parameters

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

The list of items

Example


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

ItemAction(System.Action)

Callback for each item.

Parameters

action - System.Action<ContextMenuItem>

Action, which will be executed for each item.

Example


             @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .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().ContextMenu()
                        .Name("ContextMenu")
                        .HighlightPath(true)
            )

AlignToAnchor(System.Boolean)

Specifies that ContextMenu should be shown aligned to the target or the filter element if specified.

Parameters

value - System.Boolean

The value for AlignToAnchor

AlignToAnchor()

Specifies that ContextMenu should be shown aligned to the target or the filter element if specified.

AppendTo(System.String)

The DOM element to which the ContextMenu will be appended. The element needs to be relatively positioned.

Parameters

value - System.String

The value for AppendTo

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

CopyAnchorStyles(System.Boolean)

Copies and uses the styles from the anchor.

Parameters

value - System.Boolean

The value for CopyAnchorStyles

DataTextField(System.String)

Sets the field of the data item that provides the text of the ContextMenu 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 ContextMenu 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 ContextMenu 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 ContextMenu 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 ContextMenu items.

Parameters

value - System.String

The value for DataContentField

Filter(System.String)

Specifies ContextMenu filter selector - the ContextMenu will only be shown on items that satisfy the provided selector.

Parameters

value - System.String

The value for Filter

HoverDelay(System.Double)

Specifies the delay in ms before the sub menus are opened/closed - used to avoid accidental closure on leaving.

Parameters

value - System.Double

The value for HoverDelay

Scrollable(System.Action)

If enabled, the ContextMenu displays buttons that scroll the items when they cannot fit the viewport height. By default, scrolling is disabled.

Parameters

configurator - System.Action<ContextMenuScrollableSettingsBuilder>

The configurator for the scrollable setting.

Scrollable()

If enabled, the ContextMenu displays buttons that scroll the items when they cannot fit the viewport height. By default, scrolling is disabled.

Scrollable(System.Boolean)

If enabled, the ContextMenu displays buttons that scroll the items when they cannot fit the viewport height. By default, scrolling is disabled.

Parameters

enabled - System.Boolean

Enables or disables the scrollable option.

ShowOn(System.String)

Specifies the event or events on which ContextMenu should open. By default ContextMenu will show on contextmenu event on desktop and hold event on touch devices. Could be any pointer/mouse/touch event, also several, separated by spaces.

Parameters

value - System.String

The value for ShowOn

Target(System.String)

Specifies the element on which ContextMenu should open. The default element is the document body.

Parameters

value - System.String

The value for Target

Orientation(Kendo.Mvc.UI.ContextMenuOrientation)

Specifies the orientation in which the menu items will be ordered

Parameters

value - ContextMenuOrientation

The value for Orientation

Events(System.Action)

Configures the client-side events.

Parameters

configurator - System.Action<ContextMenuEventBuilder>

The client events action.

Example


            @(Html.Kendo().ContextMenu()
                  .Name("ContextMenu")
                  .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?