We are happy to announce that in our Essential Studio® 2019 Volume 4 release, we added summary calculation support for selected rows in the WPF DataGrid control. This blog provides a walk-through of how to calculate summaries for selected rows and how to use the available options.
The DataGrid allows users to calculate summaries for:
The SummaryCalculationUnit enumeration is used to perform these operations.
To calculate a summary of selected rows in the DataGrid, set the SfDataGrid.SummaryCalculationUnit property to SelectedRows.
In the following example, a summary is calculated for group caption summary rows. This summary calculation support is also applicable for both group and table summary rows.
<syncfusion:SfDataGrid x:Name="sfDataGrid" AllowFrozenGroupHeaders="True" AutoExpandGroups="True" AutoGenerateColumns="False" ColumnSizer="Auto" SummaryCalculationUnit="SelectedRows" ItemsSource="{Binding YearlySalesDetails}" ShowColumnWhenGrouped="False" SelectionMode="Multiple">
<syncfusion:SfDataGrid.GroupSummaryRows> <syncfusion:GridSummaryRow Title="Total Sales in Year for selected products: {YearSales}" CalculationUnit="SelectedRows" ShowSummaryInRow="True"> <syncfusion:GridSummaryRow.SummaryColumns> <syncfusion:GridSummaryColumn Name="YearSales" Format="'{Sum:c}'" MappingName="Total" SummaryType="DoubleAggregate" /> <syncfusion:GridSummaryColumn Name="ProductCount" Format="'{Count:d}'" MappingName="Name" SummaryType="CountAggregate" /> </syncfusion:GridSummaryRow.SummaryColumns> </syncfusion:GridSummaryRow> </syncfusion:SfDataGrid.GroupSummaryRows>
I hope you now understand this feature and how to calculate summaries for selected rows in the WPF DataGrid. You can download a demo of calculating summaries for selected rows from our GitHub samples. To learn more about the summaries in the Syncfusion DataGrid, please refer to our documentation. You can download our 2019 Volume 4 release to check out all our new features and controls.
If you have any questions or require clarification for this control, please let us know in the comments section. You can also contact us through our support forum, Direct-Trac, or feedback portal. We are happy to assist you!