CollectionFactoryExpressionExtensions.AddFor<TRow, TProperty>(CollectionFactory<DataGridColumnBuilder<TRow>>, Expression<Func<TRow, TProperty>>) Method
Adds columns to a strongly-typed DataGrid.
Namespace: DevExtreme.AspNet.Mvc
Assembly: DevExtreme.AspNet.Core.dll
Declaration
public static DataGridColumnBuilder<TRow> AddFor<TRow, TProperty>(
this CollectionFactory<DataGridColumnBuilder<TRow>> factory,
Expression<Func<TRow, TProperty>> expression
)
Parameters
Name | Type | Description |
---|---|---|
factory | CollectionFactory<DataGridColumnBuilder<TRow>> | The DataGrid column collection factory. |
expression | Expression<Func<TRow, TProperty>> | A strongly-typed lambda expression. Returns a model property that supplies data to a column. |
Type Parameters
Name | Description |
---|---|
TRow | The model type of the strongly-typed DataGrid. |
TProperty | The type of the expression result. |
Returns
Type | Description |
---|---|
DataGridColumnBuilder<TRow> | A reference to this instance after the method is called. |
Remarks
Use this extension method to add columns to a strongly-typed DataGrid.
The method performs the following actions:
- Creates a new column
- Binds the column to the model property specified by the lambda expression
- Returns a DataGridColumnBuilder<T> instance so you can use its methods to customize the column
@(Html.DevExtreme().DataGrid<OrderViewModel>()
.Columns(columns => {
columns.AddFor(m => m.OrderDate); // call methods in a chain to customize the column
columns.AddFor(m => m.ShipCity);
})
)
Refer to Nested Options and Collections for more information.
See Also