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

Defines the fluent interface for configuring columns.

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

TColumn

TColumnBuilder

The type of the column builder.

Syntax:

C#
public abstract class GridColumnBuilderBase<TColumn, TColumnBuilder> where TColumn : IGridColumn where TColumnBuilder : GridColumnBuilderBase<TColumn, TColumnBuilder>

Inheritance: objectGridColumnBuilderBase<TColumn, TColumnBuilder>

Derived Classes: GridColumnBuilder<TColumn, TColumnBuilder>GridColumnGroupBuilder<T>

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 GridColumnBuilderBase<TColumn, TColumnBuilder> class.

C#
protected GridColumnBuilderBase(TColumn column)
Parameters:columnTColumn

The column.

Properties

Column

TColumn

Gets or sets the column.

C#
public TColumn Column { get; }
Property Value:

The column.

Methods

If set to false the column menu will not be rendered for the specific column.

C#
public TColumnBuilder ColumnMenu(bool value)
Parameters:valuebool

If true the column menu will be rendered, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).ColumnMenu(false)))

Makes the column draggable or not. By default the columns are not draggable.

C#
public TColumnBuilder Draggable(bool value)
Parameters:valuebool

If true the column is draggable, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Draggable((bool)ViewData["draggable"])))

The configurator is used to configure the exportable setting of the column.

C#
public TColumnBuilder Exportable(Action<GridColumnExportableBuilder> configurator)
Parameters:configuratorAction<GridColumnExportableBuilder>

The configurator.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Exportable(x=&gt;x.Excel(true).Pdf(false))))

If set to false the column will be excluded from the exported Excel/PDF files.

C#
public TColumnBuilder Exportable(bool value)
Parameters:valuebool

If true the column is exportable, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Exportable(false)))

Sets the HTML attributes applied to the header cell of the column.

C#
public TColumnBuilder HeaderHtmlAttributes(IDictionary<string, object> attributes, bool encodeAttributes = true)
Parameters:attributesIDictionary<string, object>

The attributes.

encodeAttributesbool

Indicates whether the attributes will be encoded. By default the HtmlAttibutes are encoded.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).HeaderHtmlAttributes(new {@class="order-header"})))

Sets the HTML attributes applied to the header cell of the column.

C#
public TColumnBuilder HeaderHtmlAttributes(object attributes, bool encodeAttributes = true)
Parameters:attributesobject

The attributes.

encodeAttributesbool

Indicates whether the attributes will be encoded. By default the HtmlAttibutes are encoded.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).HeaderHtmlAttributes(new {@class="order-header"})))

Sets the server-side header template for the column. If sorting is enabled, the template content wrapper must have a k-link CSS class.

C#
public TColumnBuilder HeaderTemplate(Action template)
Parameters:templateAction

The action defining the template.

Returns:

TColumnBuilder

Sets the header template for the column. If sorting is enabled, the template content wrapper must have a k-link CSS class.

C#
public TColumnBuilder HeaderTemplate(Func<object, object> template)
Parameters:templateFunc<object, object>

The action defining the template.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =&gt;
{
columns.Bound(c =&gt; c.Name).HeaderTemplate(@&lt;text&gt;Template&lt;/text&gt;);
}))

Sets the header template for the column. If sorting is enabled, the template content wrapper must have a k-link CSS class.

C#
public TColumnBuilder HeaderTemplate(string template)
Parameters:templatestring

The string defining the template.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =&gt;
{
columns.Bound(c =&gt; c.Name).HeaderTemplate("Template value");
}))

Hides a column. By default all columns are not hidden. Hidden columns are rendered in the output HTML but are hidden.

C#
public TColumnBuilder Hidden()
Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Hidden()))

Makes the column hidden or not. By default all columns are not hidden. Hidden columns are rendered in the output HTML but are hidden.

C#
public TColumnBuilder Hidden(bool value)
Parameters:valuebool

If true the column is hidden, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Hidden((bool)ViewData["hidden"])))

Sets the HTML attributes applied to the content cell of the column.

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

The attributes.

encodeAttributesbool

Indicates whether the attributes will be encoded. By default the HtmlAttibutes are encoded.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).HtmlAttributes(new {@class="order-cell"})))

Sets the HTML attributes applied to the content cell of the column.

C#
public TColumnBuilder HtmlAttributes(object attributes, bool encodeAttributes = true)
Parameters:attributesobject

The attributes.

encodeAttributesbool

Indicates whether the attributes will be encoded. By default the HtmlAttibutes are encoded.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).HtmlAttributes(new {@class="order-cell"})))

Sets name of the handler that sets the html attributes

C#
public TColumnBuilder HtmlAttributes(string attributesHandler)
Parameters:attributesHandlerstring

The attributes handler name.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).HtmlAttributes("htmlAttributesHandler")))

If set to false the column will remain in the side of the grid into which its own locked configuration placed it.

C#
public TColumnBuilder Lockable(bool value)
Parameters:valuebool

If true the column is lockable, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Lockable((bool)ViewData["lockable"])))

Makes the column static. By default all columns are not locked.

C#
public TColumnBuilder Locked()
Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Locked()))

Makes the column static or not. By default all columns are not locked.

C#
public TColumnBuilder Locked(bool value)
Parameters:valuebool

If true the column is locked, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Locked((bool)ViewData["locked"])))

Sets the media query condition that needs to be satisfied for a column to remain visible.

C#
public TColumnBuilder Media(string value)
Parameters:valuestring

The text.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Media("(min-width: 600px)")))

The pixel screen width below which the user will not be able to resize the column via the UI.

C#
public TColumnBuilder MinResizableWidth(int value)
Parameters:valueintReturns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).MinResizableWidth(450))
)

Sets the minimum screen width in pixels at which the column will become hidden.

C#
public TColumnBuilder MinScreenWidth(int value)
Parameters:valueintReturns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).MinScreenWidth(450))
)

If set to false the column will become non-resizable, while all the other columns remaining resizable in the grid component. In order for this property to work, grid's resizable functionality must be be enabled.

C#
public TColumnBuilder Resizable(bool value)
Parameters:valuebool

If false the column is not resizable.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Resizable(resizing =&gt; resizing.Columns(true))
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Resizable(false)))

Makes the column stickable. By default all columns are not stickable.

C#
public TColumnBuilder Stickable()
Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Stickable()))

Makes the column stickable or not. By default all columns are not stickable.

C#
public TColumnBuilder Stickable(bool value)
Parameters:valuebool

If true the column is stickable, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Stickable((bool)ViewData["stickable"])))

Makes the column sticky. By default all columns are not sticky.

C#
public TColumnBuilder Sticky()
Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Sticky()))

Makes the column sticky or not. By default all columns are not sticky.

C#
public TColumnBuilder Sticky(bool value)
Parameters:valuebool

If true the column is sticky, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Sticky((bool)ViewData["sticky"])))

Sets the title displayed in the header of the column. Any HTML entities or tags should be encoded, or use a HeaderTemplate instead.

C#
public TColumnBuilder Title(string text)
Parameters:textstring

The text.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Title("ID")))

Makes the column visible or not. By default all columns are visible. Invisible columns are not rendered in the output HTML.

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

If true the column is visible, otherwise not.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Visible((bool)ViewData["visible"])))

Sets the width of the column in pixels.

C#
public TColumnBuilder Width(int pixelWidth)
Parameters:pixelWidthint

The width in pixels.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =&gt; columns.Bound(o =&gt; o.OrderID).Width(100)))

Sets the width of the column using CSS syntax.

C#
public TColumnBuilder Width(string value)
Parameters:valuestring

The width to set.

Returns:

TColumnBuilder

Example:
C#
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =&gt;
{
columns.Bound(c =&gt; c.Name).Width("200px");
}))