Hi Lorenzo,
Solution 1:
Your requirement to display the average value for the price column in SfDataGrid
can be achieved by using GridSummaryColumn.SummaryType property and use the
built-in function in GridSummaryColumn.Format. Please refer to the below code
snippet,
|
<syncfusion:SfDataGrid.CaptionSummaryRow>
<syncfusion:GridSummaryRow ShowSummaryInRow="False">
<syncfusion:GridSummaryRow.SummaryColumns>
<syncfusion:GridSummaryColumn Name="PriceAmount"
Format="'{Average:c}
'"
MappingName="UnitPrice"
SummaryType="DoubleAggregate" />
syncfusion:GridSummaryRow.SummaryColumns>
syncfusion:GridSummaryRow>
syncfusion:SfDataGrid.CaptionSummaryRow>
<syncfusion:SfDataGrid.GroupSummaryRows>
<syncfusion:GridSummaryRow ShowSummaryInRow="False">
<syncfusion:GridSummaryRow.SummaryColumns>
<syncfusion:GridSummaryColumn Name="PriceAmount"
Format="'{Average:c}
'"
MappingName="UnitPrice"
SummaryType="DoubleAggregate" />
syncfusion:GridSummaryRow.SummaryColumns>
syncfusion:GridSummaryRow>
syncfusion:SfDataGrid.GroupSummaryRows>
|
UG Link: https://help.syncfusion.com/wpf/datagrid/summaries#aggregate-types
Solution 2:
You can calculate the summary based on custom logic using GridSummaryColumn.CustomAggregate
property. For more information related to CustomAggregate, please refer to the
below user guide documentation link,
UG Link: https://help.syncfusion.com/wpf/datagrid/summaries#custom-summaries
Please find the sample in the attachment and let us know if you have any
concerns in this.
Regards,
Vijayarasan S
Attachment: SfDataGridDemo_5d5d4a2c.zip