PDA

View Full Version : grid sorting issue



Kvel
30 Aug 2010, 10:48 PM
Hi,
Am using gxt grid to display dates, and these are represented in string format
13/Dec/2006
05/Aug/2005
11/Jan/2007

I would normally expect the above, when sorted to be
05/Aug/2005
13/Dec/2006
11/Jan/2007

but the actual sorted order by the grid is( correct w.r.t to Strings but not Dates)
05/Aug/2005
11/Jan/2007
13/Dec/2006

So how do I override the custom sorting on this date column to recognize the column values as Dates and not as Strings. Any ideas would help.

sven
31 Aug 2010, 12:10 AM
How do you store these dates? Are theses values as String inside your model or as Date? You should store them directly as Date object.

Kvel
31 Aug 2010, 1:46 AM
yeah thats a possibility, but since this has a lot of code change, was thinking more in terms of attaching a css where it can do a custom sort depending on the column names(user specified logic) instead of the default sorting of the grid.

sven
31 Aug 2010, 1:48 AM
You can set a custom store sorter, that transforms the strings that represent a date to a Date object and you sort the Date object than. So the code changes are minimal, just a new storesorter.

DaRkViDe
14 Jul 2011, 3:49 AM
hi, i've the same problem but i store data in a Date Object directly inside the model...
i was thining to implements a remote sort but if the data is already loaded, has no sense to load it again just to order it... specially inside of a not paginated grid!
Any idea?

Thanks