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
)
Public Function Columns(
    config As Action(Of BootstrapGridViewColumnCollectionBuilder)
) As T

Parameters

Type Name Description
Action<BootstrapGridViewColumnCollectionBuilder> config

An Action that configures the BootstrapGridViewColumnCollectionBuilder's functionality.

Returns

Type Description
T

A reference to this instance after the operation is completed.

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