I have a set of data where there may be 1, 2 or 3 parts of a primary piece of data. The user wants the 1,2 or 3 rows to be always grouped together, however they do not want a group by row (I've already shown them that). I've also tried an hierarchical grid and they don't want that either, because they need to look at the grid at a glance and see everything.
They want something like this:
A1A2A3B1B2C1D1D2
Now even when they click to sort any of the other columns of data, all the A's should stay together in a group.
I've been trying to figure this out for a while and I'm stumped!
Thanks in advance.
Hi,
An IGroupByEvaluator will not work here, since you are not doing any grouping.
What you need here is a SortComparer on every column in the grid.
What you would do is create a class that implements IComparer. There's only one method on this interface: Compare.
The Compare method will pass you two objects: x and y. These will be UltraGridCell objects. The first thing you will want to do is cast the objects into UltraGridCells. From there, it's an easy matter of getting the value of the column you want to sort by first. It would be something like cell.Rows.Cells["Key Column"].
What you would do then is use the cell.Value.Compare method to compare the values in the key column. If the compare method returns any non-zero values, you return that. If it returns 0, then you compare the two actual cell values being compared.
So basically, you are always sorting on the key column first, before sorting on the column the user sorted. The only time the user's sorting will ever come into play is if the values in the key column are equal.
Of course, if the key column will never have duplicate values, then the whole thing is moot, and you would be better off simply turning off sorting. :)