# ContextMenuBuilder

## Properties

### WriteAction - Func

## Methods

### Animation(System.Boolean)

Enables or disables the Animation for the ContextMenu.

#### Parameters

##### enable - `System.Boolean`

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

### Animation(System.Action)

Sets the Animation options.

#### Parameters

##### animationAction - System.Action<[PopupAnimationBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/popupanimationbuilder)>

The animation settings.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### Example

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

### DataSource(System.Action)

Configure the DataSource of the component

#### Parameters

##### configurator - System.Action<[HierarchicalDataSourceBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/hierarchicaldatasourcebuilder)>

The action that configures the DataSource of the component.

#### RETURNS

The current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### 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.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### Example

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

### Items(System.Action)

Defines the items in the menu

#### Parameters

##### addAction - System.Action<[ContextMenuItemFactory](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenuitemfactory)>

The add action.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui/contextmenuitem),T>

The action executed for every data bound item.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/navigationbindingfactory)>

The action which will configure the mappings

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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 "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](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui/contextmenuitem)>

The list of items

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### Example

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

### ItemAction(System.Action)

Callback for each item.

#### Parameters

##### action - System.Action<[ContextMenuItem](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui/contextmenuitem)>

Action, which will be executed for each item.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

#### 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.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) for method chaining.

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .AlignToAnchor(false)
            )
             
```

### AlignToAnchor()

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .AlignToAnchor(false)
            )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .AppendTo("#container")
            )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .CloseOnClick(false)
            )
             
```

### CopyAnchorStyles(System.Boolean)

Copies and uses the styles from the anchor.

#### Parameters

##### value - `System.Boolean`

The value for CopyAnchorStyles

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataTextField("Name")
             )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataUrlField("UrlField")
             )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataSpriteCssClassField("CSSField")
             )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataImageUrlField("ImageUrlField")
             )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                .Name("ContextMenu")
                .DataContentField("ContentField")
             )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .Target("#target")
                        .Filter(".item")
            )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .HoverDelay(300)
            )
             
```

### 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](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenuscrollablesettingsbuilder)>

The configurator for the scrollable setting.

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) .

### Scrollable()

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

#### RETURNS

Returns the current instance of [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) .

### 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.

#### RETURNS

Returns the current instance of [ContextMenuScrollableSettingsBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenuscrollablesettingsbuilder) .

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .ShowOn("click")
            )
             
```

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

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .Target("#target")
            )
             
```

### Orientation(Kendo.Mvc.UI.ContextMenuOrientation)

Specifies the orientation in which the menu items will be ordered

#### Parameters

##### value - [ContextMenuOrientation](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui/contextmenuorientation)

The value for Orientation

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

```
 
            @( Html.Kendo().ContextMenu()
                        .Name("ContextMenu")
                        .Orientation(ContextMenuOrientation.Vertical)
            )
             
```

### Events(System.Action)

Configures the client-side events.

#### Parameters

##### configurator - System.Action<[ContextMenuEventBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenueventbuilder)>

The client events action.

#### RETURNS

Returns the current [ContextMenuBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/contextmenubuilder) instance.

#### Example

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

### ToComponent()

Returns the internal view component.

#### RETURNS

The  instance that represents the component.

### Expression(System.String)

Sets the name of the component.

#### Parameters

##### modelExpression - `System.String`

The name.

#### RETURNS

Returns the current  instance.

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

Sets the name of the component.

#### Parameters

##### modelExplorer - `Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer`

The name.

#### RETURNS

Returns the current  instance.

### Name(System.String)

Sets the name of the component.

#### Parameters

##### componentName - `System.String`

The name.

#### RETURNS

Returns the current  instance.

### Deferred(System.Boolean)

Suppress initialization script rendering. Note that this options should be used in conjunction with Kendo.Mvc.UI.Fluent.WidgetFactory.DeferredScripts(System.Boolean,System.Boolean)

#### Parameters

##### deferred - `System.Boolean`

#### RETURNS

Returns a [DeferredWidgetBuilder](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/deferredwidgetbuilder) instance.

### HtmlAttributes(System.Object)

Sets the HTML attributes.

#### Parameters

##### attributes - `System.Object`

The HTML attributes.

#### RETURNS

Returns the current  instance.

### HtmlAttributes(System.Collections.Generic.IDictionary)

Sets the HTML attributes.

#### Parameters

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

The HTML attributes.

#### RETURNS

Returns the current  instance.

### 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.

#### RETURNS

Returns the current  instance.

### 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.

#### RETURNS

Returns the current  instance.

### Render()

Renders the component in place.

### ToHtmlString()

Returns the HTML representation of the component.

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

#### Parameters

##### writer - `System.IO.TextWriter`

##### encoder - `System.Text.Encodings.Web.HtmlEncoder`

### ToClientTemplate()

Returns the client template for the component.

### AsModule(System.Boolean)

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

#### Parameters

##### value - `System.Boolean`

#### RETURNS

Returns the current  instance.
