Display and Sorting different values
Display and Sorting different values
visionx
Posts: 22Questions: 4Answers: 5
Hi all,
I have a situation where want to display DATE in one table field and when sorting happens it should be relevant to DATE & TIME. I am returning TIMESTAMP from the database. Basically I want to display DATE in the table field and when user perform searing it should be according to the TIMESTAMP.
How could I achieving this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This is pretty simple - there's a few ways you can achieve it - for example:
1) Wrap the date in a span, and add a 'ref' attribute to the span that contains the timestamp, and then use a custom sort function for the column that sorts based on the timestamp in the ref attribute.
2) Put the timestamp in a non-visible column, and configure your date column to use the timestamp column as the sort value data source
Also you could have your database return the timestamp and the date portion of it separately. I'm sure MySQL has a function to achieve this, although I don't remember what it is.
Then use a hidden column as John says.
Thanks john_l and tangerine for the support.
I managed to get it worked as follows.
Sample Time Stamp from DB : 11/13/13 10:45AM
Configuration in Data table :