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.zipBest regards,
Haneef