Column group summary for nested table

Hello,

I have a hierachy over 4 levels with a couple nested tables. In one nested table the rows are grouped by one column. For each group I need to have a summary row with a field for each column, i.e. the summary row should look the same as the records excepting that the font is bold. The ggc is filled using a dataviewmanager.

- How do I get a summary row added looking the same as the records?
- How do I fill the summary cells manually?
- When the content of the summary cells is set, I need to access the rows within the group of rows to which the summary row belongs to. How can I access these rows?

I attached a sample picture for a better understanding.

I had a look to the samples installed but I don't see how to do this.

Thanks in advance,
Christian



sample.png_b7368553.zip

1 Reply

JJ Jisha Joy Syncfusion Team August 26, 2010 11:48 AM UTC

Hi Christian,

Thank you for using Syncfusion products.

1. You could make use of the following code for providing the look for the SummaryFieldCell as RecordFieldCells.


this.gridGroupingControl1.Appearance.SummaryFieldCell.BackColor = this.gridGroupingControl1.Appearance.RecordFieldCell.BackColor;
this.gridGroupingControl1.Appearance.SummaryFieldCell.Borders.Top = new GridBorder(GridBorderStyle.Standard);


2. You could achieve the desired behavior by handling QueryCellStyleInfo event. See the code:


private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell
&& e.TableCellIdentity.SummaryColumn != null)
{

if (e.TableCellIdentity.SummaryColumn.Name == "Sum1")
{
Group g = e.TableCellIdentity.DisplayElement.ParentGroup;

if (g.IsMainGroup)
{
e.Style.Text = null;//some value
}


}

}

}



3. You can get the summary value by using the static method GridEngine.GetSummaryText. And to get all the summary values you can loop through SummaryRowDescriptor.SummaryColumns collection of a summary row.

Here is a code snippet.

private void button1_Click(object sender, EventArgs e)
{
foreach (Element el in gridGroupingControl1.Table.DisplayElements)
{
GridRecordRow grr = el as GridRecordRow;
if (grr != null)
{
Console.WriteLine("Col1 = {0}", grr.GetRecord().GetValue("Col1"));
}
else
{
GridSummaryRow sr = el as GridSummaryRow;
if (sr != null)
{
foreach (GridSummaryColumnDescriptor scd in sr.SummaryRowDescriptor.SummaryColumns)
{
Console.WriteLine("{0} = {1}", scd.Name, GridEngine.GetSummaryText(sr.ParentGroup, scd));
}
}
}
}
}


Regards,
Jisha

Loader.
Up arrow icon