All docs
V20.2
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

MVCxGridViewColumnCollection<RowType>.Add<ValueType>(Expression<Func<RowType, ValueType>>, Action<MVCxGridViewColumn<RowType>>) Method

Adds a new column to the collection and allows you to bind this column to a model field via a lambda expression.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v20.2.dll

Declaration

public MVCxGridViewColumn<RowType> Add<ValueType>(
    Expression<Func<RowType, ValueType>> expression,
    Action<MVCxGridViewColumn<RowType>> method
)
Public Function Add(Of ValueType)(
    expression As Expression(Of Func(Of RowType, ValueType)),
    method As Action(Of MVCxGridViewColumn(Of RowType))
) As MVCxGridViewColumn(Of RowType)

Parameters

Name Type Description
expression Expression<Func<RowType, ValueType>>

Identifies the data model field to which the column is bound.

method Action<MVCxGridViewColumn<RowType>>

A delegate method that accepts the created MVCxGridViewColumn<RowType> as a parameter.

Type Parameters

Name Description
ValueType

The value type.

Returns

Type Description
MVCxGridViewColumn<RowType>

The grid view column.

Remarks

The following example illustrates how to use model-based properties and lambda expressions to create cell bands:

settings.Columns.Add(m => m.CustomerAddress, c => {
    c.Columns.Add(m => m.Country);
    c.Columns.Add(m => m.City);
    c.Columns.Add(m => m.Street);
});

or ...

var cAdress = settings.Columns.Add(m => m.CustomerAddress, c => { c.Caption = "Address"; });
cAdress.Columns.Add(m => m.CustomerAddress.Country);
cAdress.Columns.Add(m => m.CustomerAddress.City);
cAdress.Columns.Add(m => m.CustomerAddress.Street);

… if your model class contains complex properties and you rely on complex properties' types while using the Columns.Add method:

public class Customer {
    public Address CustomerAddress { get; set; }
}
public class Address {
    public string Country { get; set; }
    public string City { get; set; }
    public string Street { get; set; }
}

Breaking Change: T802552: GridView - The new Columns.Add method overload uses model-based properties and lambda expressions to create cell bands

See Also