DxSummaryItemBase<TModel>.Field Property

Specifies a data field whose values are used to calculate a summary.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v20.2.dll

Declaration

[Parameter]
[DefaultValue("")]
public string Field { get; set; }

Property Value

Type Default Description
String

String.Empty

The data field's name.

Remarks

To calculate a total or group summary in the Data Grid, add a DxDataGridSummaryItem object to the TotalSummary or GroupSummary collection. Use the item's SummaryType property to specify an aggregate function. The following functions are available: Sum, Min, Max, Avg, and Count.

The Avg, Min, Max, and Sum functions require that you set the Field property to a data field whose values take part in calculations. The Min and Max functions require a numeric or date-time data field. The Avg and Sum functions work with numeric fields only.

If you select the Count function, you can leave the Field property set to an empty string and use the ShowInColumn property to specify which column displays the summary value.

<DxDataGrid Data="@Orders">
    <Columns>
        <DxDataGridDateEditColumn Field="@nameof(Order.OrderDate)" Width="240px" />
        <DxDataGridComboBoxColumn Field="@nameof(Order.CountryId)"
                                  Caption="Ship Country"
                                  Data="@Countries"
                                  ValueFieldName="@nameof(Country.Id)"
                                  TextFieldName="@nameof(Country.CountryName)"
                                  FilteringMode="DataGridFilteringMode.Contains"
                                  Width="250px" />
        <DxDataGridColumn Field="@nameof(Order.Product)" />
        <DxDataGridSpinEditColumn Field="@nameof(Order.UnitPrice)"
                                  DisplayFormat="c"
                                  Width="120px" />
    </Columns>
    <TotalSummary>
        <DxDataGridSummaryItem Field=@nameof(Order.OrderDate)
                               SummaryType=SummaryItemType.Min
                               DisplayFormat="First: {0:D}" />
        <DxDataGridSummaryItem Field=@nameof(Order.UnitPrice)
                               SummaryType=SummaryItemType.Sum
                               DisplayFormat="Sum: {0:c}" />
        <DxDataGridSummaryItem ShowInColumn=@nameof(Order.CountryId)
                               SummaryType=SummaryItemType.Count />
   </TotalSummary>
</DxDataGrid>

Data Grid Total Summary

For more information, refer to the following help topic: Summary.

Run Demo: Data Grid - Summary

See Also