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. Image for the cookie policy date

Group caption in cells

Hi, When we group by a certain column, we display the results,in form of a long string, as below. Field_A:Value_1 - 3 items Field_B=123 Field_C=12345 Field_A:Value_2 - 322 items Field_B=1234 Field_C=987 Is there a way to set these values in seperate cells in the grouped caption. The desired format is as below. {Field_A:Value_1 - 3 items}{Field_B=123}{Field_C=12345} {Field_A:Value_2 - 322 items}{Field_B=1234}{Field_C=987} {} denotes contents of individual cells on the group caption row. Thanks.

3 Replies

AD Administrator Syncfusion Team April 6, 2005 10:49 AM UTC

You can make the caption have cells by setting some properties to draw empty Caption Summary cells. Then you can provide the values for these cells in QueryCellStyleInfo. GridSummaryRowDescriptor summaryRow1 = new GridSummaryRowDescriptor(); summaryRow1.Name = "Caption"; summaryRow1.Visible = false; this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(summaryRow1); this.gridGroupingControl1.TopLevelGroupOptions.CaptionSummaryRow = "Caption"; this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
	{
		e.Style.Text = e.TableCellIdentity.ColIndex.ToString();
	}
}
Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GGC_ExcelCopy_335bd462.zip


AD Administrator Syncfusion Team January 23, 2007 07:36 PM UTC

Is ther a way to use this code:

GridCaptionRow gcr = e.TableCellIdentity.DisplayElement as GridCaptionRow;
GridCaptionSection gcs = gcr.ParentSection as GridCaptionSection;

string s = string.Empty; //.Format(e.TableCellIdentity.GroupedColumn.GetName());
// s += string.Format("nItems: {0}, ", gcs.ParentGroup.GetChildCount());

Record r = gcs.ParentGroup.GetFirstRecord();

r = gcs.ParentGroup.Records[1];

s += r.GetValue("Trading Dept") + ", "; //column name...

s += r.GetValue("Trading Group") + ", "; //column name...

e.Style.Text = s;

and have the cloumn data display in seperate columns?

If you use

e.Style.Text = e.TableCellIdentity.ColIndex.ToString();

the index show for the corrisponding column. Is this possible with the data as well?

Thanks
Hu Anderson

>You can make the caption have cells by setting some properties to draw empty Caption Summary cells. Then you can provide the values for these cells in QueryCellStyleInfo.
>
>GridSummaryRowDescriptor summaryRow1 = new GridSummaryRowDescriptor();
>summaryRow1.Name = "Caption";
>summaryRow1.Visible = false;
>this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(summaryRow1);
>this.gridGroupingControl1.TopLevelGroupOptions.CaptionSummaryRow = "Caption";
>this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
>

>
>

>private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
>{
> if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
> {
> e.Style.Text = e.TableCellIdentity.ColIndex.ToString();
> }
>}
>

>
>Here is a little sample.
>
>http://www.syncfusion.com/Support/user/uploads/GGC_ExcelCopy_335bd462.zip
>
>


AD Administrator Syncfusion Team January 25, 2007 11:00 AM UTC

Hi Anderson,

Thank you for being patience.

Please refer to the following sample which demonstrates the intend behavior. This can be achieved by handling the QueryCellStyleInfo event. In the event, the group category key is obtained and is drawn on the caption row. The following is the code snippet
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// QueryCellStyleInfo event
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
GridCaptionRow gcr = e.TableCellIdentity.DisplayElement as GridCaptionRow;
GridCaptionSection gcs = gcr.ParentSection as GridCaptionSection;

Group grp = gcs.ParentGroup;
if (grp.IsTopLevelGroup)
return;

string value = captionSection.ParentGroup.Category.ToString();
e.Style.Text = value.ToString() ;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Sample : Grouping_2005.zip

Kindly let us know if you need any further assistance.
Have a nice day.

Best regards,
Madhan

Loader.
Live Chat Icon For mobile
Up arrow icon