Reputation: 6657
I am using jqGrid for displaying records in a user interface, and I want to sort the date column. Which returns me the date in the form of Sat, Sep 1, 01:41 AM
. How can I do that with jqGrid?
My Colmodel for that column is:
{name:'transactiontime', index:'transactiontime', sorttype:'text', align:"right"},
Upvotes: 3
Views: 11388
Reputation: 148
Use sorttype:'date'
and datefmt:
datefmt
governs the format of sorttype:date
(when datetype is set to local) and editrules {date:true} fields. It determines the expected date format for that column and uses a PHP-like date formatting. Currently ”/”, ”-”, and ”.” are supported as date separators. Valid formats are:
Of course, you can sort on server side too, if it is more painless. You can use the sidx
and sord
fields on server side.
Upvotes: 0
Reputation: 222017
Try the following formatoptions
:
{name: 'transactiontime', sorttype: 'date', align: "right", formatter: 'date',
formatoptions: {srcformat: 'ISO8601Long', newformat: 'D, M d, H:i A'}}
See the demo which is a simple modification of the demo from the answer.
The srcformat
could depend on the input format of your data.
Upvotes: 5