I have a JQGrid that has a date column. I use the date formatter to format the date to a m/d/Y format. Previously, if the format of the source date did not match the srcformat I passed in the formatoptions, it just wouldn’t format the date. JQGrid v4.4.0 now attempts to format the date no matter the source format, and comes up with dates that are wayyy off :-).
The dates I have populating into this column could either be in the correct format already (m/d/Y) or be in the format I have defined in srcformat (Y-m-dTH:i:s).
Is there a way in JQGrid 4.4.0 to not try to parse dates that do not match the srcformat?
My colModel def for column:
{name:"date", index:"date", label:"Date", width:85, jsonmap:"date", hidden: false, formatter:'date', sorttype: 'date', formatoptions:{srcformat:'Y-m-dTH:i:s', newformat:'m/d/Y'}, searchrules: { date: true } }
I solved my own issue 🙂
I created a custom formatter and used the Datejs JQuery library to help out in parsing the date.
Basically the formatter only formats the date to m/d/Y format if it is in the Y-m-dTH:i:s format; otherwise, it assumes it’s already in the m/d/Y format and leaves it be.