Using jqGrid 4.5.2 & attempting to format a date received from an XML input file in the grid & have it sort correctly. I am receiving the date in this format:
<Recordset>
<Record>
<ItemNo>12345</ItemNo>
<DATE_CREATED>March 25, 2008 14:05:30</DATE_CREATED>
<IMAGE>myImage.PDF</IMAGE>
<NOTES />
</Record>
</Recordset>
In the colModel, I am using this formatter to try to format the date.
{
name: "DATE_CREATED",
xmlmap: "Recordset>Record>DATE_CREATED",
index: "DATE_CREATED",
formatter: "date",
formatoptions: {srcformat:"F dd, Y H:i:s", newformat:"Y-m-d H:i:s"},
datefmt:"Y-m-d H:i:s"
},
The problem I am having is that some dates format fine, such as: <DATE_CREATED>November 30, 2011 11:20:13</DATE_CREATED>
However, others will not, like: <DATE_CREATED>October 02, 2012 11:44:41</DATE_CREATED>
which shows in the grid as NaN-NaN-NaN NaN:NaN:NaN.
I have the results of the GET in Firebug, and there is nothing wrong with the date - they are exactly as shown above. I am at a loss as to why some dates format okay & others do not. I have tried various srcformat, newformat & datefmt
options, none of which have made the October date display in the grid properly. The November date displays properly.
I am also concerned about the way the date column sorts. It appears to sort from left-to-right as the column is returned (April is at the beginning, September is at the end).
What am I doing wrong with this formatter? Would appreciate any thoughts.