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.
Unfortunately, activation email could not send to your email. Please try again.

Sorting Summaries And Records Calculated in PVSI (GGC)

Thread ID:

Created:

Updated:

Platform:

Replies:

62676 Jun 20,2007 07:05 AM Jun 27,2007 01:36 PM Windows Forms 4
loading
Tags: GridControl
Ian Corper
Asked On June 20, 2007 07:05 AM

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

haneefm [Syncfusion]
Replied On June 20, 2007 08:02 PM

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

Ian Corper
Replied On June 21, 2007 05:04 AM

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

Ian Corper
Replied On June 22, 2007 10:27 AM

Haneef,

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

Regards,

Marcel


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

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

CONFIRMATION

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.

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.

;