Back to Devexpress

SummaryItemBase.CalculationMode Property

wpf-devexpress-dot-xpf-dot-grid-dot-summaryitembase.md

latest4.6 KB
Original Source

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.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public GridSummaryCalculationMode? CalculationMode { get; set; }
vb
Public Property CalculationMode As GridSummaryCalculationMode?

Property Value

TypeDescription
Nullable<GridSummaryCalculationMode>

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

|

Available values:

NameDescription
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:

xaml
<dxg:GridControl x:Name="grid" SelectionMode="Row">
    <dxg:GridControl.View>
        <dxg:TableView x:Name="view"
                       SummaryCalculationMode="SelectedRows"
                       TotalSummaryPosition="Bottom" />
    </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:

xaml
<dxg:GridControl x:Name="grid" SelectionMode="Row">
    <!-- -->
    <dxg:GridControl.View>
        <dxg:TableView x:Name="view" TotalSummaryPosition="Bottom" 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

SummaryItemBase Class

SummaryItemBase Members

DevExpress.Xpf.Grid Namespace