Back to Devexpress

GridControl.CustomSummaryExistsCommand Property

wpf-devexpress-dot-xpf-dot-grid-dot-gridcontrol-03d22ab5.md

latest5.6 KB
Original Source

GridControl.CustomSummaryExistsCommand Property

Gets or sets a command that specifies 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 ICommand<RowSummaryExistsArgs> CustomSummaryExistsCommand { get; set; }
vb
Public Property CustomSummaryExistsCommand As ICommand(Of RowSummaryExistsArgs)

Property Value

TypeDescription
ICommand<RowSummaryExistsArgs>

A command that specifies which summaries should be calculated and displayed.

|

Remarks

Bind a command to the CustomSummaryExistsCommand property to maintain a clean MVVM pattern. The command works like a CustomSummaryExists event handler and allows you to specify whether to calculate a particular summary value in a View Model.

The command bound to the CustomSummaryExistsCommand property is executed before the GridControl calculates a particular summary value. This command allows you to cancel the calculation. To do this, set the RowSummaryExistsArgs.Exists property to false.

For the Total Summary, the RowSummaryExistsArgs.IsTotalSummary parameter returns true. The RowSummaryExistsArgs.SummaryItem property returns the processed summary item. You can use the summary item’s properties to identify the column that displays the summary.

For the Group Summary, the RowSummaryExistsArgs.IsGroupSummary parameter returns true. The RowSummaryExistsArgs.GroupPath property identifies a path to the processed group row. This path contains information about applied group operations. The RowSummaryExistsArgs.SummaryItem property returns the processed group summary item.

Note

The CustomSummaryExistsCommand property does not work in Server Mode.

Example

The following example calculates group summaries only for the top group level:

View Example: How to Display Group Summaries

xaml
<dxg:GridControl x:Name="grid"
                 ItemsSource="{Binding AccountList}"
                 CustomSummaryExistsCommand="{Binding CustomSummaryExistsCommand}">
                 <!-- ... -->
    <dxg:GridControl.GroupSummary>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Min"/>
        <dxg:GridSummaryItem FieldName="Age" SummaryType="Max"/>
    </dxg:GridControl.GroupSummary>
</dxg:GridControl>
csharp
using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using DevExpress.Mvvm.Xpf;
// ...
public class MainViewModel : ViewModelBase {
// ...
    [Command]
    public void CustomSummaryExistsCommand(RowSummaryExistsArgs args) {
        args.Exists = args.GroupPath[0].GroupLevel == 0;
    }
}
vb
Imports DevExpress.Mvvm
Imports DevExpress.Mvvm.DataAnnotations
Imports DevExpress.Mvvm.Xpf
' ...
Public Class MainViewModel
    Inherits ViewModelBase
' ...
    <Command>
    Public Sub CustomSummaryExistsCommand(ByVal args As RowSummaryExistsArgs)
        args.Exists = args.GroupPath(0).GroupLevel = 0
    End Sub
End Class

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

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_MVVM/MainWindow.xaml#L13

xml
ItemsSource="{Binding AccountList}"
             CustomSummaryExistsCommand="{Binding CustomSummaryExistsCommand}">
<dxg:GridControl.View>

See Also

GridControl Class

GridControl Members

DevExpress.Xpf.Grid Namespace