Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
26206 | Mar 16,2005 05:48 PM UTC | Mar 17,2005 01:06 PM UTC | WinForms | 3 |
![]() |
Tags: GridControl |
private void InitializeGroupColumns()
{
//group "Col2" using a custom categorizer and Comparer
Syncfusion.Grouping.SortColumnDescriptor cd = new SortColumnDescriptor("Numero");
cd.Categorizer = new CustomCategorizer(1);
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
ExpressionFieldDescriptor efd = new ExpressionFieldDescriptor("NumeroXX", "[Numero]");
this.gridGroupingControl1.TableDescriptor.ExpressionFields.Add(efd);
cd = new Syncfusion.Grouping.SortColumnDescriptor("NumeroXX");
cd.Categorizer = new CustomCategorizer(2);
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
efd = new ExpressionFieldDescriptor("NumeroXXX", "[Numero]");
this.gridGroupingControl1.TableDescriptor.ExpressionFields.Add(efd);
cd = new Syncfusion.Grouping.SortColumnDescriptor("NumeroXXX");
cd.Categorizer = new CustomCategorizer(3);
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
}
A better solution is based on the idea that SortColumnDescriptors do not necessarily have to be accoicated with a particular column IF you define a CustomComparer for the SortColumnDescriptor that can accept the records being compared, and return teh value you want. So, instead of adding 3 SortColumndescriptors (as above) tied to columns in the data and using the associated default comparer object, just add 3 SortColumnDescriptors with three CustomComparers that just compares the fixed Numero column. It is in this manner that you can use the same column 3 times (or more) with grouping.
private void InitializeGroupColumns()
{
this.gridGroupingControl1.TopLevelGroupOptions.CaptionText = "{Category}x-{RecordCount}";
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{Category}x-{RecordCount}";
//group "Col2" using a custom categorizer and Comparer
Syncfusion.Grouping.SortColumnDescriptor cd = new SortColumnDescriptor();
cd.Name = "1";
cd.Comparer = new CustomComparer("Numero");
cd.Categorizer = new CustomCategorizer(1, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
cd = new SortColumnDescriptor();
cd.Name = "2";
cd.Comparer = new CustomComparer("Numero");
cd.Categorizer = new CustomCategorizer(2, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
cd = new SortColumnDescriptor();
cd.Name = "3";
cd.Comparer = new CustomComparer("Numero");
cd.Categorizer = new CustomCategorizer(3, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
}
Here is your sample back modified in this manner.
http://www.syncfusion.com/Support/user/uploads/GGC_CustomCategorizer_Forum_9692f143.zip
private void InitializeGroupColumns()
{
this.gridGroupingControl1.TopLevelGroupOptions.CaptionText = "{Category}x-{RecordCount}";
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{Category}x-{RecordCount}";
Syncfusion.Grouping.SortColumnDescriptor cd = new SortColumnDescriptor();
cd.Name = "Numero";
cd.Categorizer = new CustomCategorizer(1, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
cd = new SortColumnDescriptor();
cd.Name = "2";
cd.Categorizer = new CustomCategorizer(2, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
cd = new SortColumnDescriptor();
cd.Name = "3";
cd.Categorizer = new CustomCategorizer(3, "Numero");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);
}
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.
This page will automatically be redirected to the sign-in page in 10 seconds.