Skip to main content

BootstrapGridViewBuilderBase<T>.Columns(Action<BootstrapGridViewColumnCollectionBuilder>) Method

Provides access to the Grid View column collection.

Namespace: DevExpress.AspNetCore.Bootstrap

Assembly: DevExpress.AspNetCore.Bootstrap.v18.2.dll

Declaration

public T Columns(
    Action<BootstrapGridViewColumnCollectionBuilder> config
)

Parameters

Name Type Description
config Action<BootstrapGridViewColumnCollectionBuilder>

An Action that configures the BootstrapGridViewColumnCollectionBuilder‘s functionality.

Returns

Type Description
T

A reference to this instance after the operation is completed.

Remarks

IMPORTANT

Bootstrap Controls for ASP.NET Core are in maintenance mode. We don’t add new controls or develop new functionality for this product line. Our recommendation is to use the ASP.NET Core Controls suite.

The Grid View control stores its columns in the Columns collection. Use the Add method to add a column to a Grid View’s column collection.

@model IEnumerable

@(Html.DevExpress()
    .BootstrapGridView<SalesProduct>("grid")
    .KeyFieldName(m => m.ProductID)
    .Columns(columns => {
        columns.Add(m => m.ProductName);
        columns.Add(m => m.UnitPrice);
        columns.Add(m => m.UnitsOnOrder);
        columns.AddTextColumn()
            .FieldName("Total")
            .UnboundType(UnboundColumnType.Decimal)
            .UnboundExpression("UnitsOnOrder * UnitPrice")
            .PropertiesTextEdit(properties => properties
                .DisplayFormatString("c"));
    })
    .Routes(routes => routes
        .MapRoute(r => r
            .Action("Binding")
            .Controller("GridView")))
    .Bind(Model))
See Also