Kendo.Mvc.UI.Fluent.ContextMenuBuilder

Defines the fluent API for configuring the Kendo UI ContextMenu

Methods

OpenOnClick(System.Boolean)

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

Example (ASPX)

<%= Html.Kendo().ContextMenu()
    .Name("ContextMenu")
    .OpenOnClick(true)
%>

DataSource(System.Action<Kendo.Mvc.UI.Fluent.HierarchicalDataSourceBuilder<System.Object>>)

Configure the DataSource of the component

Parameters

configurator System.Action<Kendo.Mvc.UI.Fluent.HierarchicalDataSourceBuilder>

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

Example (ASPX)

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

Items(System.Action<Kendo.Mvc.UI.Fluent.ContextMenuItemFactory>)

Defines the items in the menu

Parameters

addAction System.Action<Kendo.Mvc.UI.Fluent.ContextMenuItemFactory>

The add action.

Example (ASPX)

<%= 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 (ASPX)

<%= Html.Kendo().ContextMenu()
    .Name("ContextMenu")
    .Direction("top")
%>

BindTo(System.Collections.Generic.IEnumerable<T1>,System.Action<Kendo.Mvc.UI.ContextMenuItem,T1>)

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

The data source.

itemDataBound System.Action<Kendo.Mvc.UI.ContextMenuItem,T1>

The action executed for every data bound item.

Example (ASPX)

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

BindTo(System.Collections.IEnumerable,System.Action<Kendo.Mvc.UI.Fluent.NavigationBindingFactory<Kendo.Mvc.UI.ContextMenuItem>>)

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<Kendo.Mvc.UI.Fluent.NavigationBindingFactory>

The action which will configure the mappings

Example (ASPX)

<%= 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<Kendo.Mvc.UI.ContextMenuItem>)

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<Kendo.Mvc.UI.ContextMenuItem>

The list of items

Example (ASPX)

<%= Html.Kendo().ContextMenu()
    .Name("TreeView")
    .BindTo(model)
%>

ItemAction(System.Action<Kendo.Mvc.UI.ContextMenuItem>)

Callback for each item.

Parameters

action System.Action<Kendo.Mvc.UI.ContextMenuItem>

Action, which will be executed for each item.

Example (ASPX)

<%= 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 (ASPX)

<%= 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<Kendo.Mvc.UI.Fluent.ContextMenuScrollableSettingsBuilder>)

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<Kendo.Mvc.UI.Fluent.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 Kendo.Mvc.UI.ContextMenuOrientation

The value for Orientation

Events(System.Action<Kendo.Mvc.UI.Fluent.ContextMenuEventBuilder>)

Configures the client-side events.

Parameters

configurator System.Action<Kendo.Mvc.UI.Fluent.ContextMenuEventBuilder>

The client events action.

Example (ASPX)

@(Html.Kendo().ContextMenu()
    .Name("ContextMenu")
    .Events(events => events
        .Close("onClose")
    )
)
In this article
Not finding the help you need?