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 Summaries And Records Calculated in PVSI (GGC)

Hi,

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.

Regards,

John

4 Replies

HA haneefm Syncfusion Team 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,
Haneef


IC Ian Corper June 21, 2007 09:04 AM UTC

Haneef,

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)


Regards,

Marcel


IC Ian Corper June 22, 2007 02:27 PM UTC

Haneef,

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

Regards,

Marcel



HA haneefm Syncfusion Team 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:
http://websamples.syncfusion.com/samples/Grid.Windows/35111_h/main.htm

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon