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