We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to calulate sum of all the columns in the GridSummaryColumnDescriptor collection of a GridSummaryRowDescriptor while on that row.

Thread ID:

Created:

Updated:

Platform:

Replies:

52582 Nov 30,2006 10:21 AM Dec 5,2006 04:33 AM Windows Forms 1
loading
Tags: Grouping
James Blibo
Asked On November 30, 2006 10:21 AM

I have two summary rows define as follows...

GridSummaryColumnDescriptor[] QtySummaryColumns = new GridSummaryColumnDescriptor[SummaryColumnNames.Count];
GridSummaryColumnDescriptor[] DollarSummaryColumns = new GridSummaryColumnDescriptor[SummaryColumnNames.Count];

for (int i = 0; i < SummaryColumnNames.Count; i++)
{
string columnName = SummaryColumnNames[i];
QtySummaryColumns[i] = new GridSummaryColumnDescriptor(string.Format("_Qty{0}{1}", columnName, i), SummaryType.DoubleAggregate, columnName, "{Sum:#,###;(#,###);0}");
DollarSummaryColumns[i] = new GridSummaryColumnDescriptor(string.Format("_Qty{0}{1}", i), SummaryType.Custom, columnName, "{Total:#,###.00;(#,###.00);0.00}");
}

//summary row -> quantity
rowDescriptor = new GridSummaryRowDescriptor("QtySummaryRow", QtySummaryColumns);
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(rowDescriptor);

//summary row -> dollars
rowDescriptor = new GridSummaryRowDescriptor("DollarSummaryRow", DollarSummaryColumns);
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(rowDescriptor);



What I want to do is to show the sum of all the summarycolumn in a cell on the same summary row. I want to add another summary column to the summarycolumndescriptor collection as the first summary column to each summary row that will perform a sum ACROSS all the columns in the QtySummaryColumns
GridSummaryColumnDescriptor and do the same for the DollarSummaryColumns.

Is this possible?

Should I just have an SummaryEmptyCell and manually populate that cell with the calculated value using the QueryCellStyleInfo event? How would I accomplish this?

Administrator [Syncfusion]
Replied On December 5, 2006 04:33 AM

Hi James,

This can be achieved by handling the QueryCellStyleInfo event and set the value of SummaryEmptyCell text to sum of the all summary value present in a summary row. You can use the GetSummaries method to get all updated summaries in a GridGroup. Here is a code snippet to show this.

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.SummaryEmptyCell )
{
Element el = e.TableCellIdentity.DisplayElement;
GridTable table = e.TableCellIdentity.Table;
GridSummaryRow row = e.TableCellIdentity.DisplayElement as GridSummaryRow;
GridSummaryRowDescriptor summaryRowDescriptor = row.SummaryRowDescriptor;
int sum = 0;
foreach( ISummary summary in el.ParentGroup.GetSummaries(table))
{
Int32AggregateSummary Int32summary = summary as Int32AggregateSummary;
if( Int32summary != null)
{
sum += Int32summary.Sum ;
}
}
e.Style.Text = sum.ToString() ;
e.Style.BackColor = Color.DeepPink;
}
}

Here is a sample.
GGCSummary3_f19cec74.zip

Best Regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;