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.

GGC Sorting

Thread ID:

Created:

Updated:

Platform:

Replies:

71907 Feb 20,2008 05:00 AM Feb 25,2008 09:48 AM Windows Forms 6
loading
Tags: Grouping
Amol
Asked On February 20, 2008 05:00 AM

I am using Grid Grouping Control (GGC) and I want sorting should work in two modes,

1. Sorting on values
2. Sorting on display text

Background:

1. System has flag say “Sorting on value” and “Sorting on display text”.
2. User can chose among these flags for sorting behaviour.
3. System has some functionality where display texts and underlying values for columns may differ.
4. All columns (aprox. 300) are bound and unbound columns.
5. Display text for cell is been changed based on some logic in “QueryCellStyleInfo” using e.Style.Text = “Some Value”

Full detail is been attached in word doc.



GGC Sorting.zip

Administrator [Syncfusion]
Replied On February 20, 2008 04:17 PM

Hi Amol,

Sort by ValueMember:
>>>>>>>>>>>>>>>>>>>>
By default, GroupingGrid sort the column by its value member. Please try this code to sort the column in a grid.

this.gridGroupingControl1.TableDescriptor.SortedColumns.Add( new SortColumnDescriptor("ColumnName", ListSortDirection.Ascending) );

Sort by DisplayMember:
>>>>>>>>>>>>>>>>>>>>
Please refer to the below forum thread which implements a solution for sorting a column by its display member instead of the value member of the column. Let us know if you need any further assistance.

http://www.syncfusion.com/support/forums/message.aspx?MessageID=39048

Best Regards,
Haneef


Amol
Replied On February 21, 2008 08:16 AM

Hi Haneef,

Thanks, for your quick response. Given solution is not suitable for my requirement. Please see points listed below,

1. I already have parent and child table in GGC
2. User can add/delete rows to GGC
3. GGC is bound to entity
4. I have lot much other functionality on GGC which may break by adding one more child table to table descriptor
5. More than 300 columns (bound & unbound) need to implement this functionality

Do you have some other way to achieve sorting on display text…?

Thanks,
Amol



Amol
Replied On February 22, 2008 10:20 AM

Thanks once again Haneef,

I really appreciate you guy’s replies so promptly.

I did the same thing for unbound columns as I can change values for unbound columns in QueryValue. It works fine …!

I have bound columns and putting additional unbound columns for each bound column would be overhead on system as I mentioned we have more than 300 columns (unbound – 100, bound – 200).

I tried with custom comparer but in vain as I can access only values using custom comparer.

Can we achieve this without using additional unbound columns, another child table etc…

What I am asking if is not possible except given solution then please convey this as I have to tell business in advance….

Is Clay enjoying his vacation any updates…?








Administrator [Syncfusion]
Replied On February 22, 2008 11:02 AM

Hi Amol,

One way you can do this by adding the unbound column to grid. In that column, you need to maintain displaytext information of all columns in a GridRecord. And also you can add a custom IComparer to the SortColumnDescriptor for this unbound column to sort column based on displaytext. This can be done by setting the Comparer property on the SortColumnDescriptor. In the custom IComparer object, you can sort based on any criteria you want. Here are the codes for your reference:

//Maintain the displaytext of all columns in GridRecord.
void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e)
{
if (e.Field != null
&& e.Field.Name == "DisplaySort"
&& e.Record != null)
{
int RowIndex = e.Record.GetRowIndex();
DataRowView row = e.Record.GetData() as DataRowView;
DataRow rowCopy = row.Row.Table.NewRow();
rowCopy.ItemArray = row.Row.ItemArray;

GridGroupingControl GroupingGrid = sender as GridGroupingControl;

GridTableDescriptor td = e.TableDescriptor as GridTableDescriptor;
foreach (GridColumnDescriptor column in td.Columns)
{
if ( column.Name != "DisplaySort")
{
int field = td.NameToField(column.Name);
int colIndex = td.FieldToColIndex(field);
GridTableCellStyleInfo style = GroupingGrid.Table.GetTableCellStyle(RowIndex, colIndex);
rowCopy[column.MappingName] = style.FormattedText;
}
}
e.Value = rowCopy;
}
}
}

Please refer to the attached sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/I41636/RecordSortingbyDisplayMemberSample.zip

Best regards,
Haneef


Amol
Replied On February 25, 2008 08:18 AM

Thanks,

I am getting compile time error for,

int RowIndex = e.Record.GetRowIndex();

'Syncfusion.Grouping.Record' does not contain a definition for 'GetRowIndex'

Any other way to get row index...?

Regards,
Amol



Administrator [Syncfusion]
Replied On February 25, 2008 09:48 AM

Hi Amol,

Please try this code:

int RowIndex = e.Record.Engine.Table.NestedDisplayElements.IndexOf(e.Record );

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.

;