Skip to main content
JS

CollectionFactoryExpressionExtensions.AddFor<TField, TProperty>(CollectionFactory<PivotGridDataSourceFieldBuilder<TField>>, Expression<Func<TField, TProperty>>) Method

Adds fields to a strongly-typed PivotGrid.

Namespace: DevExtreme.AspNet.Mvc

Assembly: DevExtreme.AspNet.Core.dll

Declaration

public static PivotGridDataSourceFieldBuilder<TField> AddFor<TField, TProperty>(
    this CollectionFactory<PivotGridDataSourceFieldBuilder<TField>> factory,
    Expression<Func<TField, TProperty>> expression
)

Parameters

Name Type Description
factory CollectionFactory<PivotGridDataSourceFieldBuilder<TField>>

The PivotGrid field collection factory.

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 PivotGrid.

TProperty

The type of the expression result.

Returns

Type Description
PivotGridDataSourceFieldBuilder<TField>

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