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.

GGC customized group / group drop area

Thread ID:

Created:

Updated:

Platform:

Replies:

61880 Jun 4,2007 10:49 AM Jun 5,2007 08:38 AM Windows Forms 2
loading
Tags: GridControl
Christoph Gasser
Asked On June 4, 2007 10:49 AM

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

Rajagopal [Syncfusion]
Replied On June 4, 2007 07:04 PM

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

Christoph Gasser
Replied On June 5, 2007 08:38 AM

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

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.

;