Back to Devexpress

GridControl.CustomSummaryExists Event

wpf-devexpress-dot-xpf-dot-grid-dot-gridcontrol-a73ece70.md

latest6.8 KB
Original Source

GridControl.CustomSummaryExists Event

Enables you to specify which summaries should be calculated and displayed.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event CustomSummaryExistEventHandler CustomSummaryExists
vb
Public Event CustomSummaryExists As CustomSummaryExistEventHandler

Event Data

The CustomSummaryExists event's data class is CustomSummaryExistEventArgs. The following properties provide information specific to this event:

PropertyDescription
ExistsGets or sets whether the summary value should be calculated and displayed.
GroupLevelGets the nesting level of the group whose summary value is being calculated.
GroupRowHandleGets a value identifying the group row whose summary value is about to be calculated.
IsGroupSummaryGets whether a group summary value is about to be calculated.
IsTotalSummaryGets whether a total summary value is about to be calculated.
ItemGets a summary item whose value is about to be calculated.

Remarks

The event is raised before a particular summary value is calculated, allowing cancellation of the calculation. To cancel summary value calculation, set the event parameter’s CustomSummaryExistEventArgs.Exists parameter to false.

Note

The CustomSummaryExists event does not work in Server Mode.

If you want to maintain a clean MVVM pattern and specify whether to calculate a particular summary value in a View Model, create a command and bind it to the CustomSummaryExistsCommand property.

Example

The following example shows how to calculate group summaries and display them within group rows. A group summary is a value of the aggregate function calculated over all data rows within a group. The GridControl‘s GroupSummary collection stores group summary items.

This example uses the GridControl.CustomSummaryExists event to calculate group summaries only for the top group level:

View Example: How to Display Group Summaries

xaml
<dxg:GridControl x:Name="grid" CustomSummaryExists="OnCustomSummaryExists">
    <dxg:GridControl.View>
        <dxg:TableView AutoWidth="True"/>
    </dxg:GridControl.View>
    <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="UserName" />
        <dxg:GridColumn FieldName="RegistrationDate" />
        <dxg:GridColumn FieldName="Married" GroupIndex="0" SortOrder="Ascending" />
        <dxg:GridColumn FieldName="Age" />
    </dxg:GridControl.Columns>
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Min"/>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Max"/>
    </dxg:GridControl.GroupSummary>
</dxg:GridControl>
csharp
void OnCustomSummaryExists(object sender, CustomSummaryExistEventArgs e) {
    e.Exists = e.GroupLevel == 0;
}
vb
Private Sub OnCustomSummaryExists(ByVal sender As Object, ByVal e As CustomSummaryExistEventArgs)
    e.Exists = e.GroupLevel = 0
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomSummaryExists event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/MainWindow.xaml#L8

xml
<Grid>
    <dxg:GridControl x:Name="grid" CustomSummaryExists="OnCustomSummaryExists">
        <dxg:GridControl.View>

wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/obj/Debug/net8.0-windows/MainWindow.g.cs#L91

csharp
#line 8 "..\..\..\MainWindow.xaml"
this.grid.CustomSummaryExists += new DevExpress.Data.CustomSummaryExistEventHandler(this.OnCustomSummaryExists);

wpf-data-grid-display-group-summaries/VB/DisplayGroupSummaries_CodeBehind/obj.NetFX/Debug/MainWindow.g.vb#L90

vb
#ExternalSource("..\..\MainWindow.xaml",8)
AddHandler Me.grid.CustomSummaryExists, New DevExpress.Data.CustomSummaryExistEventHandler(AddressOf Me.OnCustomSummaryExists)

See Also

GridControl Class

GridControl Members

DevExpress.Xpf.Grid Namespace