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