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

Sorting groups by customise summary columns

Hi,

I am using GGC. I have 3 level of grouping. My requirement is I need to sort the groups based on the summary column. Summary columns are having customise summary based on some formula..
I have tried using the Custom compare implemented using Icompare. but it do the sorting only if summary is standard property i.e sum/min/max.
Please can you provide me some sample. this is very crucial requirement.

Thanks
Harshad


7 Replies

AD Administrator Syncfusion Team April 10, 2007 11:11 AM UTC

How are you doing your custom summary?

Here is a sample with a custom summary that sorts OK using either GroupSortOrderComparer or SetGroupSummarySortOrder.

http://www.syncfusion.com/Support/user/uploads/WindowsApplication124_b7b4e41.zip


HA Harshad April 10, 2007 02:24 PM UTC

Hi,

I gone through the example given. In the example you have created new summary method and property as WeightedAverage. So in Compare method when you say GetSummaryProperty you get the summary value.
In my case I have done the customise summary in querycellstyleinfo.
I have to calculate the % based on 2 columns and based on some variable. i.e some condition formula... So i can not create new summary descriptor.
Since i have done summary calculation in querycellStyleinfo without summary property. I dont get summary value in Compre method...
Please give me some pointer to work this out



AD Administrator Syncfusion Team April 10, 2007 02:33 PM UTC

Depending upon what you are doing, I am not sure you will be able to do this. Can you upload a sample project showing exactly how you are doing things?


HA Harshad April 10, 2007 03:10 PM UTC

Hi
It is not possible for me to send complete code.
here is what i am doing
In QueryCellStyleInfo Event

if (parentGroup.IsTopLevelGroup)
{
double topTotal;
if (double.TryParse(GridEngine.GetSummaryText(this.dgAttributeAnalysis.Table.TopLevelGroup, summaryRow, summaryCol),
System.Globalization.NumberStyles.Any, null, out topTotal))
{
if (topTotal == 0)
calculatedValue = "";
else
calculatedValue = string.Format("{1:F1}%", topTotal, 100d * topTotal / topTotal);
}
}
else
{
double total, part;
if (double.TryParse(GridEngine.GetSummaryText(this.dgAttributeAnalysis.Table.TopLevelGroup, summaryRow, summaryCol),
System.Globalization.NumberStyles.Any, null, out total)
&& double.TryParse(GridEngine.GetSummaryText(parentGroup, summaryRow, summaryCol),
System.Globalization.NumberStyles.Any, null, out part))
{
if (part == 0 || total == 0)
calculatedValue = "";
else
calculatedValue = string.Format("{1:F1}%", part, 100d * part / total);

}
}
e.Style.CellValue=calculatedValue

I need to calculate % for group value against Total of all group values.
So i am taking the TopLevelGroup sumamry value
& Particular group summary value then
calculating the formula as particualr GroupVal*100 / TopLevelGroupValue

So is there any way to do the sorting on such summary column. This is a key requirement. Please help


AD Administrator Syncfusion Team April 10, 2007 03:49 PM UTC

Try this. refactor the code in your QueryCellStyleInfo so you have a static method that has a signature like:

public static double GetCustomValue(Group g, ...)
{
}

Here ... represents whatever else you need to pass to be able to do your computation in the static method.

Then inside QueryCellStyleInfo, your code would look something like:

calculatedValue = GetCustomValue(parentGroup, ...).ToString();

So, now you have a method that you can call to get your value based on the group and ...'s. You can then use this sample method in your Comparer class to compute the needed values to compared based on the groups x and y passed in. (You may also have to provide other objects (like the sommaryrow) but I think these can be passed through the Comparer's constructor.


HA Harshad April 10, 2007 05:48 PM UTC

Hi,

I implemented on the same line you have suggested and it worked...Thanks a lot....

Now I can sort the group on customise summary column. but with this I have to sort the detail record level Rows also..which are not group...
Can you suggest me how to sort the record level rows also...?

Thanks
Harshad


HA haneefm Syncfusion Team June 27, 2007 05:38 PM UTC

Hi Harshad,

Your Direct-Trac incident:35111 has been updated.

Best regard,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon