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

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

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

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

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