Sir/Madam,
I am using SFDatagrid. I have added tablesummary row using following code:
GridTableSummaryRow summaryRow = new GridTableSummaryRow
{
ShowSummaryInRow = false,
Title = "Total",
Position = Position.Bottom
};
foreach (string Fld in GridTotalFld)
{
summaryRow.SummaryColumns.Add(new GridSummaryColumn()
{
Name = Fld,
MappingName = Fld,
Format = "{Sum}",
SummaryType = SummaryType.DoubleAggregate
});
}
dataGrid.TableSummaryRows.Add(summaryRow);
dataGrid.LiveDataUpdateMode = LiveDataUpdateMode.AllowSummaryUpdate;
Now I want to get total of all columns in Array or any Json format or let me know how to get TableSummary row object so I can get the total of each column like dataRowView.Row[FldName].
Thanking you.
Hi Amish,
Regarding “Get GridTableSummaryRow”
You can directly access the GridTableSummaryRow from GridTableSummaryRows collection of SfDataGrid as like below code snippet.
Code Snippet:
foreach(var summary in dataGrid.TableSummaryRows) { GridSummaryRow sum = summary as GridTableSummaryRow; for (int i=0; i< sum.SummaryColumns.Count;i++) { var col = sum.SummaryColumns[i]; … |
Please let us know if you need any further assistance.
Regards,
Suja
But how can I get the value of the column of the tablesummary Row?
Please check attached image herewith. I want the marked squared value from tablesummary row for Qty and Amout column.
You can access the GridTableSummaryRow and get the value of it using GetSummaryDisplayText method as like below code snippet.
Code Snippet:
private void Button_Clicked(object sender, EventArgs e) { var a= dataGrid.View.SummaryRows; foreach (var row in dataGrid.GetVisualContainer().RowGenerator.Items) { if(row is SpannedDataRow) { var spanneddatarow = (row as SpannedDataRow); if(spanneddatarow.RowType==RowType.TableSummaryRow) { var summaryRecordEntry= ((spanneddatarow.RowData) as SummaryRecordEntry); foreach (var col in summaryRecordEntry.SummaryRow.SummaryColumns) { var colname= col.MappingName; //get the value of every summarycolumn of summaryrow var val = SummaryCreator.GetSummaryDisplayText(summaryRecordEntry,colname, dataGrid.View); } }
} } } |
Please refer the below reference regarding GetSummaryDisplayText.
We have attached a simple sample based on your requirement. You can customize the sample as per your wish. Please let us know if you need any further assistance.
Regards,
Suja