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

GridColumnFactory

Properties

Container - Grid

Gets the selection configuration

ColumnsContainer - IGridColumnContainer

Methods

LoadSettings(System.Collections.Generic.IEnumerable)

Loads the columns and their setting.

Parameters

settings - System.Collections.Generic.IEnumerable<GridColumnSettings>

Defines the column settings

Example


                @(Html.Kendo().Grid(Model)
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]);
                    }))

Bound(System.Linq.Expressions.Expression)

Defines a bound column.

Parameters

expression - System.Linq.Expressions.Expression<Func>

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Bound(c => c.Name);
                   }))

Bound(System.String)

Defines a bound column.

Parameters

memberName - System.String

The name of the field.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Bound("Name");
                   }))

Group(System.Action)

Defines a column group.

Parameters

configurator - System.Action<GridColumnGroupBuilder>

Column configurator.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Group(x => x.Title("Group"));
                   }))

Bound(System.Type,System.String)

Defines a bound column.

Parameters

memberType - System.Type

Type of the member.

memberName - System.String

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Bound(typeof(string), "Name");
                   }))

ForeignKey(System.Linq.Expressions.Expression,System.Action,System.String,System.String)

Defines a foreign key column.

Parameters

expression - System.Linq.Expressions.Expression<Func>

The member which matches the selected item

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The foreign key dataSource

dataFieldValue - System.String

The data value field

dataFieldText - System.String

The data text field

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(p => p.CategoryID, ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName");
                   }))

ForeignKey(System.Linq.Expressions.Expression,System.Action,System.String,System.String,System.Boolean)

Defines a foreign key column.

Parameters

expression - System.Linq.Expressions.Expression<Func>

The member which matches the selected item

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The foreign key dataSource

dataFieldValue - System.String

The data value field

dataFieldText - System.String

The data text field

useServerEditor - System.Boolean

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(p => p.CategoryID, ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName", true);
                   }))

ForeignKey(System.Linq.Expressions.Expression,System.Collections.IEnumerable,System.String,System.String)

Defines a foreign key column.

Parameters

expression - System.Linq.Expressions.Expression<Func>

The member which matches the selected item

data - System.Collections.IEnumerable

The foreign data

dataFieldValue - System.String

The data value field

dataFieldText - System.String

The data text field

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(p => p.CategoryID, (System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName");
                   }))

ForeignKey(System.Linq.Expressions.Expression,Microsoft.AspNetCore.Mvc.Rendering.SelectList)

Defines a foreign key column.

Parameters

expression - System.Linq.Expressions.Expression<Func>

The member which matches the selected item

data - Microsoft.AspNetCore.Mvc.Rendering.SelectList

The foreign data

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(p => p.CategoryID, new SelectList((System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName"));
                   }))

ForeignKey(System.String,System.Collections.IEnumerable,System.String,System.String)

Defines a foreign key column.

Parameters

memberName - System.String

The member name.

data - System.Collections.IEnumerable

The data.

dataFieldValue - System.String

The data value field

dataFieldText - System.String

The data text field

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey("CategoryID", (System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName");
                   }))

ForeignKey(System.String,Microsoft.AspNetCore.Mvc.Rendering.SelectList)

Defines a foreign key column.

Parameters

memberName - System.String
data - Microsoft.AspNetCore.Mvc.Rendering.SelectList

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey("CategoryID", new SelectList((System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName"));
                   }))

ForeignKey(System.Type,System.String,System.Collections.IEnumerable,System.String,System.String)

Defines a foreign key column.

Parameters

memberType - System.Type

The member type.

memberName - System.String

The member name.

data - System.Collections.IEnumerable

The data.

dataFieldValue - System.String

The data value field

dataFieldText - System.String

The data text field

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(typeof(int), "CategoryID", (System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName");
                   }))

ForeignKey(System.Type,System.String,Microsoft.AspNetCore.Mvc.Rendering.SelectList)

Defines a foreign key column.

Parameters

memberType - System.Type

The member type.

memberName - System.String

The member name.

data - Microsoft.AspNetCore.Mvc.Rendering.SelectList

The data.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(typeof(int), "CategoryID", new SelectList((System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "CategoryName"));
                   }))

ForeignKey(System.String,System.Action,System.String,System.String)

Defines a foreign key column.

Parameters

memberName - System.String

The member name.

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The data source configuration.

dataFieldValue - System.String

The data value field.

dataFieldText - System.String

The data text field.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey("CategoryID", ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName");
                   }))

ForeignKey(System.String,System.Action,System.String,System.String,System.Boolean)

Defines a foreign key column.

Parameters

memberName - System.String

The member name.

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The data source configuration.

dataFieldValue - System.String

The data value field.

dataFieldText - System.String

The data text field.

useServerEditor - System.Boolean

Specifying if a server editor should be used.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey("CategoryID", ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName", true);
                   }))

ForeignKey(System.Type,System.String,System.Action,System.String,System.String)

Defines a foreign key column.

Parameters

memberType - System.Type

The member type.

memberName - System.String

The member name.

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The data source configuration.

dataFieldValue - System.String

The data value field.

dataFieldText - System.String

The data text field.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(typeof(int), "CategoryID", ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName");
                   }))

ForeignKey(System.Type,System.String,System.Action,System.String,System.String,System.Boolean)

Defines a foreign key column.

Parameters

memberType - System.Type

The member type.

memberName - System.String

The member name.

dataSource - System.Action<ReadOnlyDataSourceBuilder>

The data source configuration.

dataFieldValue - System.String

The data value field.

dataFieldText - System.String

The data text field.

useServerEditor - System.Boolean

Specifying if a server editor should be used.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.ForeignKey(typeof(int), "CategoryID", ds => ds.Read(r => r.Action("ReadCategories", "Home")), "CategoryID", "CategoryName", true);
                   }))

AutoGenerate(System.Boolean)

Determines if columns should be automatically generated.

Parameters

shouldGenerate - System.Boolean

If true columns should be generated, otherwise false.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.AutoGenerate(true);
                   }))

AutoGenerate(System.Action)

Determines if columns should be automatically generated.

Parameters

columnAction - System.Action<GridColumnBase>

Action which will be executed for each generated column.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.AutoGenerate(x=>x.ClientTemplate="Template");
                   }))

Template(Kendo.Mvc.UI.TemplateBuilder)

Defines a template column.

Parameters

templateBuilder - TemplateBuilder<T>

Template(System.String)

Defines a template column.

Parameters

template - System.String

Defines the template

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Template("Template value");
                   }))

Template(System.Func)

Defines a template column.

Parameters

template - System.Func<Object,Object>

Defines the template

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Template(@<text> <div> SomeContent </div> </text>);
                   }))

Command(System.Action)

Defines a command column.

Parameters

commandAction - System.Action<GridActionCommandFactory>

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Command(x=>x.Edit());
                   }))

Select()

Defines a select column.

Example


               @(Html.Kendo().Grid(Model)
                   .Name("grid")
                   .Columns(columns =>
                   {
                       columns.Select();
                   }))

In this article
Not finding the help you need?