0

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.

steve_o
  • 1,243
  • 6
  • 34
  • 60
  • 3
    I don't think that you will have success in the problem by the usage of very old jqGrid 4.5.2 version. You should update jqGrid – Oleg Feb 19 '15 at 16:58
  • I was trying to keep the version the same, but updating jqGrid to 4.7 seemed to fix the issue. Thank you for your help! – steve_o Feb 19 '15 at 18:37
  • 1
    You are welcome! I recommend you take a look in my fork of [**free jqGrid** ](https://github.com/free-jqgrid/jqGrid) where I'll publish soon new version of jqGrid wuthe many bug fixes and a lot of new features. I'll create detailed documentation and example of all new features very soon. I published just now [the answer](http://stackoverflow.com/a/28615923/315935) for example with one more new feature. – Oleg Feb 19 '15 at 20:12

0 Answers0