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

Defines the fluent API for configuring the Kendo ListBox for ASP.NET MVC.

Definition

Constructors

Initializes a new instance of the ListBox class.

C#
public ListBoxBuilder(ListBox component)
Parameters:componentListBox

The component.

Methods

If set to false, the component will not bind to the data source during initialization. In this case, the data binding will occur when the change event of the data source is fired. By default, the ListBox will bind to the data source that is specified in the configuration.

C#
public ListBoxBuilder AutoBind(bool value)
Parameters:valuebool

The value that configures the autobind.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.AutoBind(true)
)

Binds the ListBox to an IEnumerable list.

C#
public ListBoxBuilder BindTo(IEnumerable data)
Parameters:dataIEnumerable

The data source.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.BindTo(ViewBag.Attendees)
)

Binds the ListBox to a list of SelectListItem.

C#
public ListBoxBuilder BindTo(IEnumerable<SelectListItem> dataSource)
Parameters:dataSourceIEnumerable<SelectListItem>

The data source.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.BindTo(new List&lt;SelectListItem&gt;() {
new SelectListItem()
{
Text = "Cotton", Value = "1"
},
new SelectListItem()
{
Text = "Polyester", Value = "2"
}
})
)

The id of the target ListBox to which items from the source ListBox will be transferred and vice versa. If you have to transfer items from the target ListBox over its toolbar, then you also need to set its connectWith option.

C#
public ListBoxBuilder ConnectWith(string value)
Parameters:valuestring

The value that configures the connectwith.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.ConnectWith("Value")
)

Sets the data source configuration of the ListBox.

C#
public ListBoxBuilder DataSource(Action<ReadOnlyDataSourceBuilder> configurator)
Parameters:configuratorAction<ReadOnlyDataSourceBuilder>

The lambda which configures the data source

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.DataSource(source =&gt; source
.Read(read =&gt; read.Action("GetCustomers", "ListBox"))
)
)

Sets the data source of the ListBox.

C#
public ListBoxBuilder DataSource(string dataSourceId)
Parameters:dataSourceIdstring

The name of the data source

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.DataSource("dataSource")
)

The field of the data item that provides the text content of the list items. Based on this field, the component filters the data source.

C#
public ListBoxBuilder DataTextField(string value)
Parameters:valuestring

The value that configures the datatextfield.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.DataTextField("Value")
)

The field of the data item that provides the value of the component.

C#
public ListBoxBuilder DataValueField(string value)
Parameters:valuestring

The value that configures the datavaluefield.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.DataValueField("Value")
)

Indicates whether the ListBox items can be dragged and dropped.

C#
public ListBoxBuilder Draggable()
Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Draggable()
)

Indicates whether the ListBox items can be dragged and dropped.

C#
public ListBoxBuilder Draggable(Action<ListBoxDraggableSettingsBuilder> configurator)
Parameters:configuratorAction<ListBoxDraggableSettingsBuilder>

The action that configures the draggable.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Draggable(d =&gt; d.Hint("Value"))
)

Indicates whether the ListBox items can be dragged and dropped.

C#
public ListBoxBuilder Draggable(bool enabled)
Parameters:enabledbool

Enables or disables the draggable option.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Draggable(true)
)

Array of id strings which determines the ListBoxes that can drag and drop their items to the current ListBox. The dropSources option describes a one way relationship. If you want a two-way connection, then set the dropSources option on both components.

C#
public ListBoxBuilder DropSources(params string[] value)
Parameters:valuestring[]

The value that configures the dropsources.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.DropSources("Value 1", "Value 2")
)

Configures the client-side events.

C#
public ListBoxBuilder Events(Action<ListBoxEventBuilder> configurator)
Parameters:configuratorAction<ListBoxEventBuilder>

The client events action.

Returns:

ListBoxBuilder

Example:
C#
@( Html.Kendo().ListBox()
.Name("listBox")
.Events(events =&gt; events
.Change("handler")
)
)

Defines the localization texts for the ListBox. Used primarily for localization.

C#
public ListBoxBuilder Messages(Action<ListBoxMessagesSettingsBuilder> configurator)
Parameters:configuratorAction<ListBoxMessagesSettingsBuilder>

The action that configures the messages.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Messages(m =&gt; m.Tools(t=&gt;t.MoveDown("Value")))
)

Indicates whether the keyboard navigation is enabled or disabled.

C#
public ListBoxBuilder Navigatable(bool value)
Parameters:valuebool

The value that configures the navigatable.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Navigatable(true)
)

Represents the selectable options.

C#
public ListBoxBuilder Selectable(ListBoxSelectable value)
Parameters:valueListBoxSelectable

The value for Selectable

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Selectable(ListBoxSelectable.Single)
)

Specifies the item template of the ListBox.

C#
public ListBoxBuilder Template(string value)
Parameters:valuestring

The value that configures the template.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Template("Value")
)

Specifies the item template of the ListBox.

C#
public ListBoxBuilder Template<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

A Template component that configures the template.

Returns:

ListBoxBuilder

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateHandler(string value)
Parameters:valuestring

The value that configures the template.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.TemplateHandler("Value")
)

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateId(string value)
Parameters:valuestring

The value that configures the template.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.TemplateId("Value")
)

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateView(MvcHtmlString value)
Parameters:valueMvcHtmlString

The value that configures the template.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.TemplateView(Html.Partial("TemplateView"))
)

Defines the settings for displaying the toolbar of the ListBox. The toolbar allows you to execute a set of predefined actions.By default, the toolbar is not displayed. If the tools array is populated, then the toolbar and the corresponding tools are displayed.

C#
public ListBoxBuilder Toolbar(Action<ListBoxToolbarSettingsBuilder> configurator)
Parameters:configuratorAction<ListBoxToolbarSettingsBuilder>

The action that configures the toolbar.

Returns:

ListBoxBuilder

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Toolbar(toolbar =&gt;
{
toolbar.Position(Kendo.Mvc.UI.Fluent.ListBoxToolbarPosition.Right);
})
)