All docs
V21.2
21.2
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

SummaryItemBase.CalculationMode Property

Gets or sets a mode that specifies by which rows the summary value is calculated.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v21.2.Core.dll

Declaration

public GridSummaryCalculationMode? CalculationMode { get; set; }

Property Value

Type Description
Nullable<GridSummaryCalculationMode>

A mode that specifies by which rows the summary value is calculated.

Available values:

Name Description
AllRows

The summary value is calculated against all rows.

SelectedRows

The summary value is calculated against selected rows.

Mixed

The summary value is calculated against selected rows if their number is more than one; otherwise, against all rows.

Remarks

The GridControl can calculate summaries against selected rows and cells:

Set the DataViewBase.SummaryCalculationMode property to SelectedRows / Mixed to make the GridControl calculate all summaries within its view against selected rows:

<dxg:GridControl x:Name="grid" SelectionMode="Row">
    <dxg:GridControl.View>
        <dxg:TableView x:Name="view"
                       SummaryCalculationMode="SelectedRows"
                       ShowTotalSummary="True" />
    </dxg:GridControl.View>
    <dxg:GridControl.TotalSummary>
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" DisplayFormat="Sum={0:$0.00}" />
    </dxg:GridControl.TotalSummary>
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" DisplayFormat="Sum={0:$0.00}" />
    </dxg:GridControl.GroupSummary>
</dxg:GridControl> 

Run Demo: Data Grid - Web Style Row Selection

You can create an individual summary for selected rows/cells and set its SummaryItemBase.CalculationMode property to SelectedRows / Mixed:

<dxg:GridControl x:Name="grid" SelectionMode="Row">
    <!-- -->
    <dxg:GridControl.View>
        <dxg:TableView x:Name="view" ShowTotalSummary="True" ShowGroupedColumns="True" />
    </dxg:GridControl.View>
    <dxg:GridControl.TotalSummary>
        <!-- The first summary against selected rows -->
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" ShowInColumn="Total"
                             DisplayFormat="Selection Total=${0:N}" CalculationMode="SelectedRows" />
        <!-- The second summary against all rows -->
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" ShowInColumn="Total" 
                             DisplayFormat="Total=${0:N}" />
    </dxg:GridControl.TotalSummary>
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Total" SummaryType="Sum" 
                             DisplayFormat="Grand Total=${0:N}" CalculationMode="SelectedRows" />
    </dxg:GridControl.GroupSummary>
</dxg:GridControl> 

Run Demo: Data Grid - Multi Row Selection

Note

The GridControl in Server Mode or bound to ICollectionView does not calculate summaries for selection.

See Also