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

GGC customized group / group drop area

I've implemented a customized group and when I load the form the grid is grouping perfectly fine. But when I remove the grouping (draging from the group drop area) and try to group on the specified column again the grid is grouping by default not by my customized group.

Any idea where I can define the customized group to be used everytime the grid is grouped by that column?

BR

2 Replies

RA Rajagopal Syncfusion Team June 4, 2007 11:04 PM UTC

Hi Christoph,

In the TableDescriptor.GroupedColumns.Changed event, you can add your custom categorizer object to the SortColumnDescriptor. To create custom Categorizer objects, you define classes that implement ICategorizer. When you do this, whenever you group a specfic column it will be custom grouped.

Please refer this forum thread for a sample application
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=57064

Also, check this knowledgebase article that shows you "How to create custom group in a GridGroupingControl?".
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=147

Regards,
Rajagopal


CG Christoph Gasser June 5, 2007 12:38 PM UTC

Thank you for your help!

If anybody has the same problem, here is my solution (perhaps it helps somebody):

I've created a "helper class" (attached file) that is handling the grouping (date grouping like outlook).

In the initialisation part of the form's code I've the following lines od code:

snip---snip---snip
this.ggc1.TableDescriptor.GroupedColumns.Changed += new Syncfusion.Collections.ListPropertyChangedEventHandler(GroupedColumns_Changed);
CustomizedGridGrouping("ColumnName");
snip---snip---snip

Then I've added the following parts:

snip---snip---snip
private void GroupedColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
SortColumnDescriptor column = e.Item as SortColumnDescriptor;
if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Insert)
{
if (column.Name == "ColumnName")
{
CustomizedGridGrouping("ColumnName");
}
}
}

private void CustomizedGridGrouping(string column)
{
Syncfusion.Grouping.SortColumnDescriptor cd = new Syncfusion.Grouping.SortColumnDescriptor(column, ListSortDirection.Descending);
cd.Categorizer = new GridGroupingHelper.GridGroupingHelper_Categorizer();
//cd.Comparer = new GridGroupingHelper.GridGroupingHelper_Comparer();
if (this.ggc1.TableDescriptor.GroupedColumns.Contains(column))
this.ggc1.TableDescriptor.GroupedColumns.Remove(column);
this.ggc1.TableDescriptor.GroupedColumns.Add(cd);
this.ggc1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(CustomizedGridGrouping_Format);
}

private void CustomizedGridGrouping_Format(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.GroupedColumn != null && e.TableCellIdentity.DisplayElement.ParentGroup != null
&& e.TableCellIdentity.DisplayElement.ParentGroup.Category is int
)
{
if (e.TableCellIdentity.DisplayElement is CaptionRow
&& e.TableCellIdentity.GroupedColumn.Name == "ColumnName")
{
e.Style.CellValue = String.Format("{0}: {1} {2}", (string)GridGroupingHelper.GridGroupingHelper_Format.ColumnLabelByDateGroup((int)e.TableCellIdentity.DisplayElement.ParentGroup.Category), e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount(), "YourText");
}
if (this.ggc1.Table.Records.Count > 0)
this.ggc1.Table.Records[0].ParentGroup.IsExpanded = true;
}
}
snip---snip---snip


Hope this helps anybody.

GridGroupingHelper.zip

Loader.
Live Chat Icon For mobile
Up arrow icon