I have a column in my jqGrid that currently shows the date in 'd/m/y' format. It is formatted from a date and time string of the format 'Y-m-d H:i:s' and is sorted by date only. The current colModel is like the following:
{name: 'published_date', index: 'published_date', formatter: 'date', formatoptions: {newformat: 'd/m/y'}}
The sortname
property is set to 'published_date'.
So this is working fine. What I'm trying to do now is sort with both the date and time because some of the rows that fall on the same date are in a seemingly random order. I still want to maintain the display format of 'd/m/y' but just sort it with the original date/time that it was formatted from.
I've tried some suggestions I've found, but none of them have worked for me yet. For example, someone suggested converting the date to an integer and trying to sort on that and then format it as 'd/m/y'. There also doesn't seem to be a sort field for datetime that works.
{name: 'published_date', index: 'published_date', sorttype: 'datetime', formatter: 'date', formatoptions: {newformat: 'd/m/y', srcformat: 'Y-m-d H:i:s'}}
If there aren't any built-in mechanisms in jqGrid to handle this, what would you suggest for a custom solution?
Using jqGrid 4.7.0, datatype is json and an example of the data from the server for published_date is "2015-03-04 18:38:12"