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

users group of subgroup number

Hello. I use the default group and get many groups with small number of items. How to unite groups, for example, groups with 1-2 items to one? I want to combine the group with only 1 item to another group. Example is attach.

Attachment: screen_example_13c68430.zip

3 Replies

SA Solai A L Syncfusion Team May 15, 2015 01:16 PM UTC

Hi Svyatoslav,

Thank you for your interest in Syncfusion products.

We have analyzed your reported scenario. Our Syncfusion GridGroupingControl has support to customize grouping using IComparer and SortColumnDescriptor. Please refer the below provided code snippet and sample for further clarification. In this sample we have grouped the columns based a column value(similar to the image provided by you).

Code snippet:

//group "Col2" using a custom categorizer and Comparer

Syncfusion.Grouping.SortColumnDescriptor cd = new Syncfusion.Grouping.SortColumnDescriptor("Col2");

cd.Categorizer = new CustomCategorizer();

cd.Comparer = new CustomComparer();

this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);

//defines a group and returns a group category object (here returns 1 through 5)

public static int GetCategory(string i)

{

int ret = 0;


if (i == "Group0")

{

ret = 1;

}

else if (i == "Group1")

{

ret = 2;

}

else

ret = 3;


return ret;

}


#region IGroupByColumnCategorizer Members


public object GetGroupByCategoryKey(SortColumnDescriptor column, bool isForeignKey, Record record)

{

return GetCategory(record.GetValue(column).ToString());

}


public int CompareCategoryKey(SortColumnDescriptor column, bool isForeignKey, object category, Record record)

{

return GetCategory(record.GetValue(column).ToString()) - (int)category;

}


Sample:
http://www.syncfusion.com/downloads/support/forum/119155/CustomGrouping-CS1667817960.zip

Please refer the below KB for reference. This is similar to you query. In this KB also column based custom grouping is done.
KB:
http://www.syncfusion.com/kb/498/how-to-do-custom-grouping-in-gridgroupingcontrol

Please let us know if you have any other concerns.

Thanks & Regards,
AL.Solai.



SR Svyatoslav Razmyslov replied to Solai A L May 18, 2015 03:05 PM UTC

Hi Svyatoslav,

Thank you for your interest in Syncfusion products.

We have analyzed your reported scenario. Our Syncfusion GridGroupingControl has support to customize grouping using IComparer and SortColumnDescriptor. Please refer the below provided code snippet and sample for further clarification. In this sample we have grouped the columns based a column value(similar to the image provided by you).

Code snippet:

//group "Col2" using a custom categorizer and Comparer

Syncfusion.Grouping.SortColumnDescriptor cd = new Syncfusion.Grouping.SortColumnDescriptor("Col2");

cd.Categorizer = new CustomCategorizer();

cd.Comparer = new CustomComparer();

this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(cd);

//defines a group and returns a group category object (here returns 1 through 5)

public static int GetCategory(string i)

{

int ret = 0;


if (i == "Group0")

{

ret = 1;

}

else if (i == "Group1")

{

ret = 2;

}

else

ret = 3;


return ret;

}


#region IGroupByColumnCategorizer Members


public object GetGroupByCategoryKey(SortColumnDescriptor column, bool isForeignKey, Record record)

{

return GetCategory(record.GetValue(column).ToString());

}


public int CompareCategoryKey(SortColumnDescriptor column, bool isForeignKey, object category, Record record)

{

return GetCategory(record.GetValue(column).ToString()) - (int)category;

}


Sample:
http://www.syncfusion.com/downloads/support/forum/119155/CustomGrouping-CS1667817960.zip

Please refer the below KB for reference. This is similar to you query. In this KB also column based custom grouping is done.
KB:
http://www.syncfusion.com/kb/498/how-to-do-custom-grouping-in-gridgroupingcontrol

Please let us know if you have any other concerns.

Thanks & Regards,
AL.Solai.


GetCategory() method is a grouping of the contest, but my data can be of different types and must be sorted in a standard way. The essence of my question: how to unite groups with one element of the same group?

For example:
---------------------------------------------------------------------------
17 lines - with default group we will see the following groups (7):

Group: cplus-dem.c (Count=1)                   <== bad group
Group: floatformat.c (Count=2)
Group: libbfd.c (Count=2)
Group: merge.c (Count=1)                          <== bad group
Group: regex.c (Count=7)
Group: simple-object-coff.c (Count=1)       <== bad group
Group: sort.c (Count=3)


must obtain (5)


Group: floatformat.c (Count=2)
Group: libbfd.c (Count=2)
Group: regex.c (Count=7)
Group: sort.c (Count=3)
Group: other files (Count=3)   <== (for cplus-dem.c, merge.c and simple-object-coff.c)
--------------------------------------------------------------------------------------------------
How can I do that?


SA Solai A L Syncfusion Team May 20, 2015 01:42 AM UTC

Hi Svyatoslav,

Thank you for your update.

We have prepared a sample as per your requirement. For thisGrouping based on IComparer is not required. We can achieve this by performing a grouping based on adjacent column value in QueryValue event. Please refer the below provided sample and let us know if you have any other concerns.

Sample:
http://www.syncfusion.com/downloads/support/forum/119155/WindowsFormsApplication21_(4)-1651798363.zip

Please let us know if you have any other concerns.

Thanks & Regards,
Al.Solai

Loader.
Live Chat Icon For mobile
Up arrow icon