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

Defines the fluent interface for configuring navigation items

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

TItem

The type of the item.

TBuilder

The type of the builder.

Syntax:

C#
public abstract class NavigationItemBuilder<TItem, TBuilder> where TItem : NavigationItem<TItem> where TBuilder : NavigationItemBuilder<TItem, TBuilder>, IHideObjectMembers

Inheritance: objectNavigationItemBuilder<TItem, TBuilder>

Derived Classes: ContentNavigationItemBuilder<TItem, TBuilder>ContextMenuItemBuilderDropDownTreeItemBuilderMenuItemBuilderTreeViewItemBuilder

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

Initializes a new instance of the NavigationItemBuilder<TItem, TBuilder> class.

C#
protected NavigationItemBuilder(NavigationItem<TItem> item, ViewContext viewContext)
Parameters:itemNavigationItem<TItem>

The item.

viewContextViewContext

The ViewContext object

Properties

Item

TItem

C#
protected TItem Item { get; }

ViewContext

ViewContext

C#
public ViewContext ViewContext { get; set; }

Methods

Sets the action to which the item should navigate

C#
public TBuilder Action(RouteValueDictionary routeValues)
Parameters:routeValuesRouteValueDictionary

The route values of the Action method.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("Index").Action(MVC.Home.Index(3).GetRouteValueDictionary()))
)

Sets the action to which the item should navigate

C#
public TBuilder Action(string actionName, string controllerName, object routeValues)
Parameters:actionNamestring

Name of the action.

controllerNamestring

Name of the controller.

routeValuesobject

The route values.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("Index").Action("Index", "Home", new {id, 1}))
)

Sets the action to which the item should navigate

C#
public TBuilder Action(string actionName, string controllerName, RouteValueDictionary routeValues)
Parameters:actionNamestring

Name of the action.

controllerNamestring

Name of the controller.

routeValuesRouteValueDictionary

The route values.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("Index").Action("Index", "Home", new RouteValueDictionary {"id", 1}))
)

Sets the action to which the item should navigate

C#
public TBuilder Action(string actionName, string controllerName)
Parameters:actionNamestring

Name of the action.

controllerNamestring

Name of the controller.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("Index").Action("Index", "Home"))
)

Makes the item navigate to the specified controllerAction method.

C#
public TBuilder Action<TController>(Expression<Action<TController>> controllerAction) where TController : Controller
Parameters:controllerActionExpression<Action<TController>>

The action.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add().Text("First Item")
.Action&lt;HomeController&gt;(controller =&gt; controller.Index()))

)

Sets the HTML content which the item should display.

C#
public TBuilder Content(Action value)
Parameters:valueAction

The action which renders the content.

Returns:

TBuilder

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

Sets the HTML content which the item should display.

C#
public TBuilder Content(Func<object, object> value)
Parameters:valueFunc<object, object>

The content wrapped in a regular HTML tag or text tag (Razor syntax).

Returns:

TBuilder

Example:
C#
@(Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add()
.Text("First Item")
.Content(
@&lt;text&gt;
Some text
&lt;strong&gt; First Item Content&lt;/strong&gt;
&lt;/text&gt;
);
)
)

Sets the HTML content which the item should display as a string.

C#
public TBuilder Content(string value)
Parameters:valuestring

The action which renders the content.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add()
.Text("First Item")
.Content("&lt;strong&gt; First Item Content&lt;/strong&gt;");
)
.Render();
)

Sets the HTML attributes of the content element of the item.

C#
public TBuilder ContentHtmlAttributes(IDictionary<string, object> attributes)
Parameters:attributesIDictionary<string, object>

The attributes.

Returns:

TBuilder

Sets the HTML attributes of the content element of the item.

C#
public TBuilder ContentHtmlAttributes(object attributes)
Parameters:attributesobject

The attributes.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add().Text("First Item")
.Content(() =&gt; { ) &lt;strong&gt;First Item Content&lt;/strong&gt; @( })
.ContentHtmlAttributes(new {@class="first-item-content"})
)
)

Enables or disables the item. Disabled item cannot be clicked, expanded or open (depending on the item type - menu, tabstrip, panelbar).

C#
public TBuilder Enabled(bool value)
Parameters:valueboolReturns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("First Item").Enabled((bool)ViewData["enabled"]))
)

Sets whether the Text property should be encoded when the item is rendered.

C#
public TBuilder Encoded(bool isEncoded)
Parameters:isEncodedbool

Whether the property should be encoded. Default: true.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("&lt;strong&gt;First Item&lt;/strong&gt;").Encoded(false))
)

Sets the HTML attributes applied to the outer HTML element rendered for the item

C#
public TBuilder HtmlAttributes(IDictionary<string, object> attributes)
Parameters:attributesIDictionary<string, object>

The attributes.

Returns:

TBuilder

Sets the HTML attributes applied to the outer HTML element rendered for the item

C#
public TBuilder HtmlAttributes(object attributes)
Parameters:attributesobject

The attributes.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().HtmlAttributes(new {@class="first-item"}))
)

Sets the HTML attributes for the item image.

C#
public TBuilder ImageHtmlAttributes(IDictionary<string, object> attributes)
Parameters:attributesIDictionary<string, object>

The attributes.

Returns:

TBuilder

Sets the HTML attributes for the item image.

C#
public TBuilder ImageHtmlAttributes(object attributes)
Parameters:attributesobject

The attributes.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add().Text("First Item")
.ImageUrl("~/Content/first.png")
.ImageHtmlAttributes(new {@class="first-item-image"}))
)

Sets the URL of the image that should be displayed by the item.

C#
public TBuilder ImageUrl(string value)
Parameters:valuestring

The value.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("First Item").ImageUrl("~/Content/first.png"))
)
C#
public TBuilder LinkHtmlAttributes(IDictionary<string, object> attributes)
Parameters:attributesIDictionary<string, object>Returns:

TBuilder

C#
public TBuilder LinkHtmlAttributes(object attributes)
Parameters:attributesobjectReturns:

TBuilder

Sets the route to which the item should navigate.

C#
public TBuilder Route(string routeName, object routeValues)
Parameters:routeNamestring

Name of the route.

routeValuesobject

The route values.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("First Item").Route("Default", new {id, 1}))
)

Sets the route to which the item should navigate.

C#
public TBuilder Route(string routeName, RouteValueDictionary routeValues)
Parameters:routeNamestring

Name of the route.

routeValuesRouteValueDictionary

The route values.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("First Item").Route("Default", new RouteValueDictionary {"id", 1}))
)

Sets the route to which the item should navigate.

C#
public TBuilder Route(string routeName)
Parameters:routeNamestring

Name of the route.

Returns:

TBuilder

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

Selects or unselects the item. By default items are not selected.

C#
public TBuilder Selected(bool value)
Parameters:valueboolReturns:

TBuilder

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

Sets the sprite CSS class names.

C#
public TBuilder SpriteCssClasses(params string[] cssClasses)
Parameters:cssClassesstring[]

The CSS classes.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items
.Add().Text("First Item")
.SpriteCssClasses("icon", "first-item"))
)

Sets the text displayed by the item.

C#
public TBuilder Text(string value)
Parameters:valuestring

The value.

Returns:

TBuilder

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

Returns the inner navigation item

C#
public TItem ToItem()
Returns:

TItem

Sets the URL to which the item should navigate

C#
public TBuilder Url(string value)
Parameters:valuestring

The value.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("www.example.com").Url("http://www.example.com"))
)

Makes the item visible or not. Invisible items are not rendered in the output HTML.

C#
public TBuilder Visible(bool value)
Parameters:valuebool

The value.

Returns:

TBuilder

Example:
C#
@( Html.Kendo().Menu()
.Name("Menu")
.Items(items =&gt; items.Add().Text("First Item").Visible((bool)ViewData["visible"]))
)