Hello,
I have a scenario where i have a group by column which is a concatenation of a numeric value and a string value.
But when i try to sort the column, i want the result set to be sorted on the numeric value and not on the concatenation.
There is a column in the grid which is hidden and which has the numeric values of the group by column.
I tried using the _AfterSortChange(object sender, BandEventArgs e) event and then adding the sort by
e.Band.SortedColumns.Add("NumericValues", sortIndicator == SortIndicator.Descending);
But then it removes the group by and just sorts by the numeric column. But i also want to keep the group by column.
How can i fix this scenario. Help needed please.
Thanks
Shailendra
I added the below class
class MySortComparer : IComparer {
public MySortComparer() { }
public int Compare(object x, object y) {
UltraGridCell xCell = (UltraGridCell)x; UltraGridCell yCell = (UltraGridCell)y; xCell = xCell.Row.Cells["NumericValues"]; yCell = yCell.Row.Cells["NumericValues"]; int val1 = Convert.ToInt16(xCell.Value); int val2 = Convert.ToInt16(yCell.Value); if (val1 < val2) return -1; else if(val1 == val2) return 0; else return 1;
}
and then added the below line in the _AfterSortChange(object sender, BandEventArgs e) event.
e.Band.Columns["NumericValuesAndStringValues"].SortComparer = new MySortComparer();
It works fine. But is this right and is there a better way to do it.
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue?
Thank you for using Infragistics Components.
Thanks for following up. The code that i wrote in the post worked. It is very similar to the suggestion you gave.