HI,
I have a sfDataGrid with 2 custom grouping, id like to show a summary on the second grouping ?
_________________________________________________________________________
void GroupDC()
{
if (DCPurGrid.GroupColumnDescriptions.Count > 0)
{
for (int i = 0; i < DCPurGrid.GroupColumnDescriptions.Count; i++)
{
DCPurGrid.GroupColumnDescriptions.RemoveAt(i);
}
}
DCPurGrid.GroupColumnDescriptions.Add(new GroupColumnDescription()
{
ColumnName = "Date",
KeySelector = (string ColumnName, object o) =>
{
var item = (o as DataRowView).Row["Date"];
DateTime d = Convert.ToDateTime(item);
switch (d.Month)
{
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
return d.Year.ToString() + " Dry Cows";
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return d.AddYears(-1).Year.ToString() + " Dry Cows";
}
return "Other";
}
});
DCPurGrid.GroupColumnDescriptions.Add(new GroupColumnDescription()
{ ColumnName = "Type",
KeySelector = (string ColumnName, object o) =>
{
var item = (o as DataRowView).Row["Type"];
string i = item.ToString();
switch (i)
{
case "DC":
return "Tubes";
case "S":
return "Sealers";
}
return "Other";
}
});
DCPurGrid.Columns["Type"].Visible = false;
}
The grouing works correctly but i would like to show a total one of the columns ("Cows") in the second grouping and I am confused as to how to add it ??
Thanks Peter
Hi Peter,
Your requirement can be achieved by using GroupSummaryRow in SfDataGrid.
Please refer the below code snippet,
|
// Creates the GridSummaryRow. GridSummaryRow groupSummaryRow1 = new GridSummaryRow(); groupSummaryRow1.Name = "GroupSummary"; groupSummaryRow1.ShowSummaryInRow = false;
// Creates the GridSummaryColumn. GridSummaryColumn summaryColumn1 = new GridSummaryColumn(); summaryColumn1.Name = "Cows"; summaryColumn1.SummaryType = SummaryType.DoubleAggregate; summaryColumn1.Format = "Total Cows : {Sum}"; summaryColumn1.MappingName = "Cows";
// Adds the GridSummaryColumn in SummaryColumns collection. groupSummaryRow1.SummaryColumns.Add(summaryColumn1);
// Adds the summary row in the GroupSummaryRows collection. this.sfDataGrid1.GroupSummaryRows.Add(groupSummaryRow1); |
UG Link: https://help.syncfusion.com/windowsforms/datagrid/summaries#displaying-group-summary-for-column
Please find the sample in the attachment and let us know if you have any
concerns in this.
Regards,
Vijayarasan S
HI Vijayarasan,
That is working perfectly now !!!
Thanb
Hi Peter,
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.
Regards,
Vijayarasan S