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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sorting Summaries And Records Calculated in PVSI (GGC)

Thread ID:





62676 Jun 20,2007 11:05 AM UTC Jun 27,2007 05:36 PM UTC WinForms 4
Tags: GridControl
Ian Corper
Asked On June 20, 2007 11:05 AM UTC


I am doing similar to Harshad Kulkarni in 59254.

I wish to sort summaries AND records by a field calculated in PrepareViewStyleInfo.
The calculation is based on other fields in the same row.

Did you have a response to Harshad's last query i.e. How do you sort the Records?
In this circumstance i can't see how to get hold of the Record in order to do the calculation.



haneefm [Syncfusion]
Replied On June 21, 2007 12:02 AM UTC

Hi Marcel,

You can get the record from TableControlPrepareViewStyleInfo event by using record.GetValue method. Below is a code snippet

GridTableCellStyleInfo style = e.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;
if (el.Kind == DisplayElementKind.Record)
Record rec = el.GetRecord();
rec.GetValue("ColumnName"); //get the value from record.
rec.SetValue("ColumnName","fieldvalue"); set the value from record.

How do you sort the Records?
If you want to sort the records insted of sorting the summary descriptor. You can reset the IComparer of the SortColumnDescriptor in a TableControlQueryAllowSort event .Below is a small sample that implement this task. Please try this and let me know if this helps.

Sample : WindowsApplication124.zip

Best regards,

Ian Corper
Replied On June 21, 2007 09:04 AM UTC


I'm not sure that this solves my problem. I'll elaborate ...

The calculation that i am doing from QueryViewStyleInfo (not PVSI as i mistakenly said in my last message) involves other fields and varies depending upon other settings in my application.

I found that, for performance reasons, doing the calculation in QueryViewStyleInfo is preferable to using expressions (and changing the expresssions when the calculation needs to change).

So to enable sorting of summaries i took the advice given to Harshad Kulkarni in 59254 and put the calculation in a static method which
i can call from the Comparer and from QVSI. i.e. setting the GroupSortOrderComparer of the SortColumnDescriptor to specify my IComparer object which has access to the Group and therefore the other summaries in that Group which it uses to call the calculation method.

So i need a comparer object, which will behave similarly for Record sorting, that can access the rest of the Record (and take any other info needed in its constructor)



Ian Corper
Replied On June 22, 2007 02:27 PM UTC


My requirement to sort Records calculated in QVSI is now quite urgent. Can you advise on how to do this please?



haneefm [Syncfusion]
Replied On June 27, 2007 05:36 PM UTC

Hi Marcel,

One way to do this would be to have an extra unbound column in Grid say ‘A+B’ to keep track of the expression values in a row. You can handle the TableControlQueryAllowSort event to cancel default sort on the grouped column 'C' and apply sort on grid using the unboundfield to re-order the records in a group.This will be very faster.

Please refer this sample for the implementation:

Best regards,


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon