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

Defines the fluent API for configuring the Kendo UI ListView

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

T

Syntax:

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

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

Implements: IHtmlContent

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

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

The ListView<T> 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>

Returns the current ListViewBuilder<T> instance.

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

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

The value for AutoBind

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Binds the ListView to a list of objects

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

The data source.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

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

Binds the ListView to a list of objects

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

The IEnumerable list of objects.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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 templateHandler)
Parameters:templateHandlerstring

The view which contains the template.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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

Specifies ListView alternating item template.

C#
public ListViewBuilder<T> ClientAltTemplateView(IHtmlContent templateView)
Parameters:templateViewIHtmlContent

The view which contains the template.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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 templateHandler)
Parameters:templateHandlerstring

The function handler which contains the template.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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

Specifies ListView item template.

C#
public ListViewBuilder<T> ClientTemplateView(IHtmlContent templateView)
Parameters:templateViewIHtmlContent

The view which contains the template.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

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

Defines the type of element that holds the listview content.

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

The value for ContentElement

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Binds the ListView to a DataSource.

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

The DataSourceBuilder<TModel> configurator.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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("productsLitView")
.DataSource("dataSource1")
)

Enables ListView editing.

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

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView()
.Name("ListView")
.Events(events =&gt; events
.Cancel("onCancel")
)
)

Flex layout settings

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

The ListViewFlexSettingsBuilder<T> for the flex setting.

Returns:

ListViewBuilder<T>

Returns the current instance of ListViewBuilder<T> .

Grid layout settings.

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

The ListViewGridSettingsBuilder<T> for the grid setting.

Returns:

ListViewBuilder<T>

Returns the current instance of ListViewBuilder<T> .

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>

Returns the current ListViewBuilder<T> instance.

Indicates whether keyboard navigation is enabled/disabled.

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

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Indicates whether keyboard navigation is enabled/disabled.

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

The value for Navigatable

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Allows paging of the data.

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

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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>

Returns the current ListViewBuilder<T> instance.

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

Specifies whether item selection is allowed. By default selection is disabled

C#
public ListViewBuilder<T> Selectable(Action<ListViewSelectableSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ListViewSelectableSettingsBuilder<T>>

The ListViewSelectableSettingsBuilder<T> for the selectable setting.

Returns:

ListViewBuilder<T>

Returns the current instance of ListViewBuilder<T> .

Specifies whether item selection is allowed. By default selection is disabled

C#
public ListViewBuilder<T> Selectable(bool enabled)
Parameters:enabledbool

Enables or disables the selectable option.

Returns:

ListViewBuilder<T>

Returns the current instance of ListViewSelectableSettingsBuilder<T> .

Enables selection in the specified selection mode.

C#
public ListViewBuilder<T> Selectable(ListViewSelectionMode mode)
Parameters:modeListViewSelectionMode

The selection mode.

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.

Example:
C#
@(Html.Kendo().ListView&lt;ProductViewModel&gt;()
.Name("productsLitView")
.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 value)
Parameters:valuestring

The value for TagName

Returns:

ListViewBuilder<T>

Returns the current ListViewBuilder<T> instance.