BootstrapGridViewBuilderBase<T>.TotalSummary(Action<BootstrapSummaryItemCollectionBuilder>) Method
Provides access to total summary items.
Namespace: DevExpress.AspNetCore.Bootstrap
Assembly: DevExpress.AspNetCore.Bootstrap.v18.2.dll
#Declaration
public T TotalSummary(
Action<BootstrapSummaryItemCollectionBuilder> config
)
#Parameters
Name | Type | Description |
---|---|---|
config | Action<Bootstrap |
An Action that configures the Bootstrap |
#Returns
Type | Description |
---|---|
T | A reference to this instance after the operation is completed. |
#Remarks
IMPORTANT
Bootstrap Controls for ASP.
A total summary represents the value of an aggregate function calculated over all rows within the grid and is displayed within the grid footer, provided that the ShowFooter option is enabled. The TotalSummary method adds a total summary item to the shown footer.
Use a summary item’s FieldName
method to specify a data field which will be used for summary calculation. The summary is displayed in the column specified using the FieldName
method. You can also use the ShowInColumn method to explicitly specify the column that should display the summary.
There are five predefined aggregate functions that you can use to calculate summaries: Sum, Min, Max, Average, and Count. You can define the summary type for each summary item using the SummaryType method.
The example below demonstrates how to add Count-type and Sum-type summaries to Grid View.
@(Html.DevExpress()
.BootstrapGridView("grid")
.KeyFieldName("OrderID")
.Settings(settings => settings.ShowFooter(true))
.Columns(columns => {
columns
.Add()
.FieldName("CompanyName");
columns
.AddTextColumn()
.FieldName("UnitPrice")
.PropertiesTextEdit(properties => properties.DisplayFormatString("c"));
columns
.Add()
.FieldName("Quantity");
columns
.AddTextColumn()
.FieldName("Total")
.UnboundType(UnboundColumnType.Decimal)
.UnboundExpression("UnitPrice * Quantity")
.PropertiesTextEdit(properties => properties.DisplayFormatString("c"));
})
.TotalSummary(summary => {
summary
.Add()
.FieldName("CompanyName")
.SummaryType(SummaryItemType.Count);
summary
.Add()
.FieldName("Total")
.SummaryType(SummaryItemType.Sum);
})
.Routes(routes => routes
.MapRoute(r => r
.Controller("GridView")
.Action("TotalSummary")))
.Bind(Model))