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

Defines the fluent interface for configuring the ListView<T>.

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

T

Syntax:

C#
public class ListViewBuilder<T> : WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>, IHtmlString where T : class

Inheritance: objectWidgetBuilderBase<ListView<T>, ListViewBuilder<T>>ListViewBuilder<T>

Implements: IHtmlString

Inherited Members WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ToComponent()WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.Name(string)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.Deferred(bool)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ModelMetadata(ModelMetadata)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.HtmlAttributes(object)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.AsModule(bool)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.Render()WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ScriptAttributes(object, bool)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ToHtmlString()WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ToClientTemplate()WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.ToString()WidgetBuilderBase<ListView<T>, ListViewBuilder<T>>.Componentobject.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 ListView<T> class.

C#
public ListViewBuilder(ListView<T> component)
Parameters:componentListView<T>

The component.

Methods

Sets an aria-label attribute on the ListView content element (the element with role listbox or list).

C#
public ListViewBuilder<T> AriaLabel(string value)
Parameters:valuestring

The value for AriaLabel

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.AriaLabel("ListView with products")
)

Specifies if the ListView should be automatically bound on initial load. This is only possible if AJAX binding is used, and widget is not initialy populated on the server.

C#
public ListViewBuilder<T> AutoBind(bool value)
Parameters:valuebool

If true ListView will be automatically data bound, otherwise false

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.AutoBind(false)
)

Binds the ListView to a list of objects

C#
public ListViewBuilder<T> BindTo(IEnumerable dataSource)
Parameters:dataSourceIEnumerable

The IEnumerable list of objects.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.BindTo((IEnumerable)ViewData["Products"])
)

Binds the ListView to a list of objects

C#
public ListViewBuilder<T> BindTo(IEnumerable<T> dataSource)
Parameters:dataSourceIEnumerable<T>

The data source.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.BindTo((IEnumerable&lt;ProductViewModel&gt;) ViewData["Products"])
)

Renders border around the listview element.

C#
public ListViewBuilder<T> Bordered(bool value)
Parameters:valuebool

The value for Bordered

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Bordered(true)
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Renders border around the listview items. Valid values are: all: renders borders around listview items.; horizontal: renders top border of listview items. Useful when setting layout: "flex" and flex.direction: column. or vertical: renders top border of listview items. Useful when setting layout: "flex" and flex.direction: row..

C#
public ListViewBuilder<T> Borders(string value)
Parameters:valuestring

The value for Borders

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Borders("horizontal")
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Specifies ListView alternating item template.

C#
public ListViewBuilder<T> ClientAltTemplate<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The template component which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientAltTemplate(Html.Kendo()
.Template()
.AddHtml("&lt;p&gt;${data.ProductName}&lt;/p&gt;")
)
)

Specifies ListView alternating item template.

C#
public ListViewBuilder<T> ClientAltTemplateHandler(string template)
Parameters:templatestringReturns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientAltTemplateHandler("listViewHandler")
)

Specifies ListView alternating item template.

C#
public ListViewBuilder<T> ClientAltTemplateId(string templateId)
Parameters:templateIdstring

The Id of the script element which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientAltTemplateId("listViewTemplate")
)

Specifies ListView alternating item template.

C#
public ListViewBuilder<T> ClientAltTemplateView(MvcHtmlString template)
Parameters:templateMvcHtmlString

The view which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientAltTemplateView(Html.Partial("listViewTemplate"));
)

Specifies ListView item template.

C#
public ListViewBuilder<T> ClientTemplate<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The template component which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientTemplate(Html.Kendo()
.Template()
.AddHtml("&lt;p&gt;${data.ProductName}&lt;/p&gt;")
)
)

Specifies ListView item template.

C#
public ListViewBuilder<T> ClientTemplateHandler(string template)
Parameters:templatestringReturns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientTemplateHandler("listViewHandler")
)

Specifies ListView item template.

C#
public ListViewBuilder<T> ClientTemplateId(string templateId)
Parameters:templateIdstring

The Id of the script element which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientTemplateId("listViewTemplate")
)

Specifies ListView item template.

C#
public ListViewBuilder<T> ClientTemplateView(MvcHtmlString template)
Parameters:templateMvcHtmlString

The view which contains the template.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ClientTemplateView(Html.Partial("listViewTemplate"))
)

Defines the type of element that holds the listview content. The default value is "div".

C#
public ListViewBuilder<T> ContentElement(string value)
Parameters:valuestring

The value for ContentElement

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.ContentElement("article")
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Binds the ListView to a DataSource.

C#
public ListViewBuilder<T> DataSource(Action<ListViewAjaxDataSourceBuilder<T>> configurator)
Parameters:configuratorAction<ListViewAjaxDataSourceBuilder<T>>

The DataSourceBuilder<TModel> configurator.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Binds the ListView to an existing DataSource instance.

C#
public ListViewBuilder<T> DataSource(string dataSourceId)
Parameters:dataSourceIdstring

The name of the client DataSource instance.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().DataSource&lt;ProductViewModel&gt;()
.Name("dataSource1")
.Ajax(dataSource =&gt; dataSource
.PageSize(10)
.Read(read =&gt; read.Action("Products_Read", "DataSource"))
)
)
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.DataSource("dataSource1")
)

Enables ListView editing.

C#
public ListViewBuilder<T> Editable()
Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Editable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Model(model =&gt; model.Id("ProductID"))
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.Update(update =&gt; update.Action("Products_Update", "ListView"))
.PageSize(21)
)
)

Configures the ListView editing settings.

C#
public ListViewBuilder<T> Editable(Action<ListViewEditingSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ListViewEditingSettingsBuilder<T>>

The editing settings configurator.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Editable(edit =&gt; edit.Enabled(true))
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Model(model =&gt; model.Id("ProductID"))
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.Update(update =&gt; update.Action("Products_Update", "ListView"))
.PageSize(21)
)
)

Configures the client-side events.

C#
public ListViewBuilder<T> Events(Action<ListViewEventBuilder> configurator)
Parameters:configuratorAction<ListViewEventBuilder>

The client events action.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Events(events =&gt; events
.DataBound("onDataBound")
)
)

Flex layout settings

C#
public ListViewBuilder<T> Flex(Action<ListViewFlexSettingsBuilder> configurator)
Parameters:configuratorAction<ListViewFlexSettingsBuilder>

The configurator for the flex setting.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Flex(flex =&gt; flex.Direction("row").Wrap("nowrap"))
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Grid layout settings.

C#
public ListViewBuilder<T> Grid(Action<ListViewGridSettingsBuilder> configurator)
Parameters:configuratorAction<ListViewGridSettingsBuilder>

The configurator for the grid setting.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Grid(grid =&gt; grid.Rows(2).Cols(5).Gutter(false))
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Specify the layout of listview content. Valid options are: flex: This is equivalent to display: flex. It defines a flex container and enables a flex context for all its direct children. Think of flex items as primarily laying out either in horizontal rows or vertical columns. or grid: This is equivalent to display: grid. It defines the element as a grid container and establishes a new grid formatting context for its contents..

C#
public ListViewBuilder<T> Layout(string value)
Parameters:valuestring

The value for Layout

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Layout("flex")
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Enables keyboard navigation.

C#
public ListViewBuilder<T> Navigatable()
Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Navigatable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Allows paging of the data.

C#
public ListViewBuilder<T> Pageable()
Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Pageable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Allows paging of the data.

C#
public ListViewBuilder<T> Pageable(Action<ListViewPageableBuilder> pagerAction)
Parameters:pagerActionAction<ListViewPageableBuilder>

Use builder to define paging settings.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Pageable(paging=&gt;paging.Numeric(true).PreviousNext(true).PageSizes(false))
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

If set, the ListView will display a scrollbar when the content exceeds the ListView's height. By default, scrolling is disabled.

C#
public ListViewBuilder<T> Scrollable()
Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.Scrollable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

In endless scrolling mode the listview should be configured to display a scrollbar. Scrolling to the end of the scrollbar will load more items (equal to the pageSize number) and append them to the listview DOM element utill all items are loaded and displayed.

C#
public ListViewBuilder<T> Scrollable(ListViewScrollableMode mode)
Parameters:modeListViewScrollableMode

The value for Scrollable

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.Scrollable(ListViewScrollableMode.Endless)
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Enables single item selection.

C#
public ListViewBuilder<T> Selectable()
Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Selectable()
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Enables selection in the specified selection mode.

C#
public ListViewBuilder<T> Selectable(Action<ListViewSelectionSettingsBuilder> selectionAction)
Parameters:selectionActionAction<ListViewSelectionSettingsBuilder>

Use builder to define the selection mode.

Returns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.Selectable(select=&gt;select.Mode(ListViewSelectionMode.Multiple))
.DataSource(dataSource =&gt; dataSource
.Ajax()
.Read(read =&gt; read.Action("Products_Read", "ListView"))
.PageSize(21)
)
)

Specifies ListView wrapper element tag name.

C#
public ListViewBuilder<T> TagName(string tagName)
Parameters:tagNamestringReturns:

ListViewBuilder<T>

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsListView")
.TagName("div")
)