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

Defines the fluent API for configuring the Kendo UI ListBox

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Syntax:

C#
public class ListBoxBuilder : WidgetBuilderBase<ListBox, ListBoxBuilder>, IHtmlContent

Inheritance: objectHelperResultWidgetBuilderBase<ListBox, ListBoxBuilder>ListBoxBuilder

Implements: IHtmlContent

Inherited Members WidgetBuilderBase<ListBox, ListBoxBuilder>.ToComponent()WidgetBuilderBase<ListBox, ListBoxBuilder>.Expression(string)WidgetBuilderBase<ListBox, ListBoxBuilder>.Explorer(ModelExplorer)WidgetBuilderBase<ListBox, ListBoxBuilder>.Name(string)WidgetBuilderBase<ListBox, ListBoxBuilder>.Deferred(bool)WidgetBuilderBase<ListBox, ListBoxBuilder>.HtmlAttributes(object)WidgetBuilderBase<ListBox, ListBoxBuilder>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<ListBox, ListBoxBuilder>.ScriptAttributes(object, bool)WidgetBuilderBase<ListBox, ListBoxBuilder>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<ListBox, ListBoxBuilder>.Render()WidgetBuilderBase<ListBox, ListBoxBuilder>.ToHtmlString()WidgetBuilderBase<ListBox, ListBoxBuilder>.WriteTo(TextWriter, HtmlEncoder)WidgetBuilderBase<ListBox, ListBoxBuilder>.ToClientTemplate()WidgetBuilderBase<ListBox, ListBoxBuilder>.AsModule(bool)WidgetBuilderBase<ListBox, ListBoxBuilder>.ComponentWidgetBuilderBase<ListBox, ListBoxBuilder>.ContainerHelperResult.WriteTo(TextWriter, HtmlEncoder)HelperResult.WriteActionobject.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 ListBoxBuilder class.

C#
public ListBoxBuilder(ListBox component)
Parameters:componentListBox

Methods

If set to false, the widget 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 for AutoBind

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

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 for ConnectWith

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

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 widget filters the data source.

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

The value for DataTextField

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

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

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

The value for DataValueField

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Returns the current instance of ListBoxDraggableSettingsBuilder .

Indicates whether the ListBox items can be dragged and dropped.

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

The ListBoxDraggableSettingsBuilder for the draggable setting.

Returns:

ListBoxBuilder

Returns the current instance of ListBoxBuilder .

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

Returns the current instance of ListBoxDraggableSettingsBuilder .

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

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

The value for DropSources

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

Example:
C#
@(Html.Kendo().ListBox()
.Name("ListBox")
.Events(events =&gt; events
.Add("onAdd")
)
)

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

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

The ListBoxMessagesSettingsBuilder for the messages setting.

Returns:

ListBoxBuilder

Returns the current instance of ListBoxBuilder .

Indicates whether the keyboard navigation is enabled or disabled.

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

The value for Navigatable

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Returns the current ListBoxBuilder instance.

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 for Template

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

Example:
C#
@(Html.Kendo().ListBox()
.Name("listBox")
.Template(Html.Kendo().Template()
.AddHtml("&lt;div class='ship-details'&gt;")
.AddComponent(btn =&gt; btn
.Button()
.Name("button")
.Content("Details")
.ThemeColor(ThemeColor.Primary)
)
.AddHtml("&lt;/div&gt;")
);
)

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

Returns the current ListBoxBuilder instance.

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateHandler(string templateHandler)
Parameters:templateHandlerstring

The handler that returs the template for Template

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateId(string templateId)
Parameters:templateIdstring

The ID of the template element for Template

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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

Specifies the item template of the ListBox.

C#
public ListBoxBuilder TemplateView(IHtmlContent templateView)
Parameters:templateViewIHtmlContent

The view that contains the template for Template

Returns:

ListBoxBuilder

Returns the current ListBoxBuilder instance.

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 ListBoxToolbarSettingsBuilder for the toolbar setting.

Returns:

ListBoxBuilder

Returns the current instance of ListBoxBuilder .