Hi Mariusz Juszkiewicz,
To programmatically retrieve the GridSummaryColumn value in SfDataGrid, use the
GetSummaryDisplayTextForRow and GetSummaryDisplayText methods in SummaryCreator.
SfDataGrid allows you, to
retrieve the value of summary rows by using the SummaryCreator.GetSummaryDisplayTextForRow
method when GridSummaryRow.ShowSummaryInRow is true. Refer to the below
code snippet,
private void btnTableSummaryRowClicked(object sender, RoutedEventArgs e)
{
if
(sfDataGrid.View != null && sfDataGrid.View.Records != null &&
sfDataGrid.View.Records.TableSummaries.Count > 0)
{
var summary = this.sfDataGrid.View.Records.TableSummaries[0];
//SfDataGrid allows you, to retrieve the
value of summary rows by using the SummaryCreator.GetSummaryDisplayTextForRow
method
//when GridSummaryRow.ShowSummaryInRow is
true.
var value =
SummaryCreator.GetSummaryDisplayTextForRow(summary, this.sfDataGrid.View);
MessageBox.Show(value);
}
}
|
And you can also retrieve the value of each summary column by using the SummaryCreator.GetSummaryDisplayText
method when GridSummaryRow.ShowSummaryInRow is false. Refer to the below
code snippet,
private void btnTableSummaryRowClicked(object sender, RoutedEventArgs e)
{
if
(sfDataGrid.View != null && sfDataGrid.View.Records != null &&
sfDataGrid.View.Records.TableSummaries.Count > 0)
{
var summary = this.sfDataGrid.View.Records.TableSummaries[0];
//Retrieves the summary row value of the
UnitPrice and CustomerName column.
//SfDataGrid allows you, to retrieve the value of summary
rows by using the SummaryCreator.GetSummaryDisplayText method
//when GridSummaryRow.ShowSummaryInRow is
false.
var valueOfUnitPrice
= SummaryCreator.GetSummaryDisplayText(summary, "UnitPrice", this.sfDataGrid.View);
var
valueOfCustomerName = SummaryCreator.GetSummaryDisplayText(summary, "CustomerName", this.sfDataGrid.View);
MessageBox.Show("UnitPrice Summary
Column Value: " + valueOfUnitPrice + "\nCustomerName Summary Column Value: " + valueOfCustomerName);
}
}
|
UG Link: https://help.syncfusion.com/wpf/datagrid/summaries
Find the sample in the attachment.
Regards,
Vijayarasan S
If this post is helpful, please
consider Accepting it as the solution so that other members can locate it more
quickly.
Attachment:
Sample_e2cd95b4.zip