I am using with the WinGrid features, and I have a problem on Date Time formatting.
My project requirement is that, I have to show "Time" which is DateTime field on Database. I have implemented that successfully.However, when I try to sort against this field, it will ignore the Date (Because the grid show the time only)
For example:DB Store "03/12/2008 14:57"The Grid Show1457
Is that possible to override the grid sorting behaviour to adept that? Or is that I do something wrong with it (Since the 1457 which I prepared in DataTable that is the datasource of the grid)
Tks and RegardsAnDrew
Hi Andrew,
So you want to show only the time, but sort on both the date and the time? That seems like an odd user experience. Will the users understand they times appear out of order?
Anyway, the grid's sorting is based on what is visible to the user. You can change the sorting behavior, though, by applying a SortComparer to the grid column. You just create a class that implement IComparer and implement the Compare method. The x and y parameters that get passed into the Compare method will be two UltraGridCell objects and you can decide which is greater.
I think I got the idea how to implement this,
for like I will set the date into a hidden field (The user want to show the time in the grid but they want to hide the date, but they have requirement that the time sorting should be follow by date and time)
for eg:
Grid Output(String) DataBase (DateTime)1400 1400 28Oct081400 1400 29Oct082000 2000 20Oct080100 0100 10Oct08
They want the sort order should be in this format:0100 0100 10Oct082000 2000 20Oct081400 1400 28Oct081400 1400 29Oct08
So in this stituation, how can I fulfill this?
Or, if I set the DateTime field in the hidden columns, but the problem is, how can I click sort A column but the logic is change to sort the B Column.
The comparer need two cells (x and y) How can I change the cells from Column A to Column B when clicking column A header ...
Regards
Andrew