Sort group by summary

I'm using GridGroupingControl to show kind of statistic.

I have two kind of summary:

- by number of contracts (row count)

- by value of contracts (sum of column value)

Sorting on summary on one of that summary working, I'm usinng SetGroupSummarySortOrder


It is possible sorting by combination of this summaries ?

e.g if number of rows is the same I would have sort by value.





9 Replies

SS Sampathnarayanan Sankaralingam Syncfusion Team February 10, 2022 02:29 PM UTC

Hi Krzysztof Adamowicz,


We are checking the possibilities to achieve your requirement. We will check and update you with more details on February 14, 2022.


Regards,

Sampath Narayanan.S



SS Sampathnarayanan Sankaralingam Syncfusion Team February 15, 2022 10:48 PM UTC

Hi Krzysztof Adamowicz,


We are checking the possibilities to achieve your requirement. We will check and update you with more details on February 17, 2022.


Regards,

Sampath Narayanan.S



SS Sampathnarayanan Sankaralingam Syncfusion Team February 16, 2022 07:33 PM UTC

Hi Krzysztof Adamowicz,
You can achieve the requirement of yours by creating custom comparer and setting to the SortColumnDescriptor.GroupSortOrderComparer property as shown in the below code.

gsd.GroupSortOrderComparer = new CustomComparer(summaryColumn2.GetSummaryDescriptorName(), "Count");
CustomComparer.summaryDescriptorName1 = summaryColumn1.GetSummaryDescriptorName();
CustomComparer.propertyName1 = "Average";
public class CustomComparer : IGroupSortOrderComparer
{
string summaryDescriptorName;
string propertyName;
public static string summaryDescriptorName1;
public static string propertyName1;
public CustomComparer(string summaryDescriptorName, string propertyName)
{
this.summaryDescriptorName = summaryDescriptorName;
this.propertyName = propertyName;
}
public int Compare(object x, object y)
{
Group gx = (Group)x;
Group gy = (Group)y;
bool strongTyped = false;
if (strongTyped)
{
// strong typed (propertyName is ignored ...)
DoubleAggregateSummary dasx = (DoubleAggregateSummary)gx.GetSummary(summaryDescriptorName);
DoubleAggregateSummary dasy = (DoubleAggregateSummary)gy.GetSummary(summaryDescriptorName);
int v = dasx.Average.CompareTo(dasy.Average);
return v;
}
else
{
// using reflection (slower but more flexible using propertyName)
object vx = gx.GetSummaryProperty(summaryDescriptorName, propertyName);
object vy = gy.GetSummaryProperty(summaryDescriptorName, propertyName);
if(int.Parse(vx.ToString()) == int.Parse(vy.ToString()))
{
object vx1 = gx.GetSummaryProperty(summaryDescriptorName1, propertyName1);
object vy2 = gy.GetSummaryProperty(summaryDescriptorName1, propertyName1);
return ((IComparable)vx1).CompareTo(vy2);
}
return ((IComparable)vx).CompareTo(vy);
}
}
public string[] GetDependantFields(TableDescriptor td)
{
SummaryDescriptor sd = td.Summaries[summaryDescriptorName];
if (sd == null)
{
return new string[0];
}
return new string[] { sd.MappingName };
}
#endregion
}

Please refer the Sample and let us know If you have any concerns.
Regards,
Sampath Narayanan.S




KA Krzysztof Adamowicz February 19, 2024 05:33 PM UTC

Not working for me :-(

I have SummaryRows which names "Suma".

It has SummaryColumns which names "WizytaSum", this is sum of value Wizyta in table.

I set CaptionText in ChildGroupOption as that:

{Category} - Wizyty: {Suma.WizytySum} 

It is working, I have caption for example: UTECO - Wizyty: 3


Now I will have add sorting on this value.

I have own "comparer"

public class VisitGroupComparer : IGroupSortOrderComparer

This method workin because I tested it using records count (gxRecordCount = gx.GetRecordCount())


Bu when I use 

object vx = gx.GetSummaryProperty("Suma", "WizytySum");

It is not working because value vs is null.












CM Chidanand Murugaiah Syncfusion Team February 22, 2024 04:48 PM UTC

Hi Krzyztof Adamowicz,


We are currently analyzing the reported scenario, we need some time to complete the validation and will provide an update on or before February 23, 2024.


Regards,

Chidanand M.



CM Chidanand Murugaiah Syncfusion Team February 23, 2024 04:07 PM UTC

Hi Krzyztof Adamowicz,


We regret the inconvenience.

We are still analyzing the reported scenario, we need some time to analyze this reported scenario on our source level and will provide an update on or before February 28, 2024.

We appreciate the patience until then.


Regards,

Chidanand M.



CM Chidanand Murugaiah Syncfusion Team February 28, 2024 05:03 PM UTC

Hi Krzyztof Adamowicz,


We have analyzed the reported scenario on our end, we suspect that reported scenario is occurs due to the propertyName. If the propertyName is not property provided then the vx will be null. Could you please review the provided sample and if possible, can you please replicate the reported scenario in the provided sample and revert us back.

Providing these details will help us better understand the issue and work towards finding a solution promptly.


Regards,

Chidanand M.


Attachment: Sort_by_Summary_Demo_4c1d37c2.zip


KA Krzysztof Adamowicz February 28, 2024 07:47 PM UTC

Working!

It was bad argument.

When I change

object vx = gx.GetSummaryProperty("Suma", "WizytySum");

to

object vx = gx.GetSummaryProperty("SumaWizytySum ", "Sum");

then it is OK


Thanx

Krzysztof






CM Chidanand Murugaiah Syncfusion Team February 29, 2024 04:07 AM UTC

Hi Krzysztof Adamowicz,


Glad that your issue is resolved!! Please let us know if you require any additional assistance. We are happy to help you.


Regards,

Chidanand M.


Loader.
Up arrow icon