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

Customize text in GroupCaptionCell

I have a ggc that has 1 level of grouping.
Assuming my the name of my group column name is 'ModelName', the ggc always display the text in the GroupCaptionCell as {GroupName}: {GroupNameText} - {} items

for example, if my current model group is 'Cars', the GroupCaptionCEll would show

ModelName: Cars - 23 items.

In my actual datasource, I also have the ModelID along with the ModelName. How do I add the ModelID as part of the ModelName in the GroupCaptionCell. The ModelID and ModelName will always have a 1 to 1 match.

3 Replies

AD Administrator Syncfusion Team December 11, 2006 04:30 AM UTC

Hi James,

You can handle the QueryCellStyleInfo event to set the Style property of the GroupCaptionCell. See the below code snippet for more details.

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell
&& e.TableCellIdentity.GroupedColumn != null &&
e.TableCellIdentity.GroupedColumn.Name == "Cars" )
{
e.Style.Text = "YourDisplayText Here";
}
}

Best Regards,
Haneef


JB James Blibo December 11, 2006 04:46 PM UTC

I understand how to do that... I guess my issue is-> How do I get access to the records collection for this this GroupCaptionCell is the parent of?


AD Administrator Syncfusion Team December 12, 2006 04:20 AM UTC

Hi James,

You can get the caption row from the displayelement and access the related records using the GridCaptionRow. 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.GroupCaptionCell
&& e.TableCellIdentity.GroupedColumn != null &&
e.TableCellIdentity.GroupedColumn.Name == "Cars" )
{
// get the CaptionRow from the DisplayElement.
GridCaptionRow gr = e.TableCellIdentity.DisplayElement as GridCaptionRow;

//Accessing the related records in a Group...
foreach(Record rec in gr.ParentGroup.Records)
{ Console.WriteLine("Records:" + rec); }
}
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon