Hello,
I have an ultragrid that has a set of rows bound to it.
When the user clicks on one of the column header I want to intercept and provide a custom sorting algorithm instead of the built in ascending and descending sort.
Is it possible with the Grid events.
Thanks
Yes, you can use an IComparer as I mentioned above. The Compare method will pass you a couple of cells from col3. The UltraGridCell object has a reference to it's Row, and from the Row, you can access the Cells collection to get the values of the other cells in the same row. You can then use those cell values to do any kind of comparison that you want and determine how they should be sorted.
Hi,
I have a ultragrid that has col1, col2, col3, and col4. When I click on the header of col3, I want to sort the data by col3, col1, col2 and col4, if I click on the header of col2, the data should be sorted by col2, col1, col3, and col4. Is there any way to do it?
Thanks a lot!
The IComparer.Compare method will pass you two UltraGridCell objects. So as long as one of them isn't null, you can get the Column from the cell.
I thought about it. But I also need to know which column was clicked/ which column is being sorted.
I don;t wan to write 10 different Icomparer functions for each column.
After Initial checks is there a way to give the control back to the in built sorting algorithm or somehow know which column is being sorted.
You can do this by assigning an IComparer class to the SortComparer property of the column.