jQWidgets Forums
jQuery UI Widgets › Forums › Grid › formatDate not working in IE11 when String is passed
Tagged: jqxgrid datetime formatDate
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 10 years, 4 months ago.
-
Author
-
Hi,
My grid has a datetime column which we pass the timezone (using json). I apply the following cellrenderer:function startDateStampCellRenderer(rowIndex, columnfield, value, defaulthtml, columnproperties, rowData) { var date = $.jqx.dataFormat.formatdate(value, "MMM dd HH:mm:ss, yyyy"); return "<div title='{1}' style='overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin: 5px;'>{1}</div>".assign(date.toString()); }
The input value is “2015-01-21 09:10:28 -05:00” for both IE, “Wed Jan 21 2015 12:00:45 GMT-0500 (Eastern Standard Time)” for Chrome. When running in Internet Explorer 11, formatDate simply returns the string back to me without applying formatting.
Chrome works just fine.I stepped inside jqx-all.js code and found this code is causing formatdate to exit in IE:
if (typeof value === 'string') { return value; }
Already tried applying a dataFormat = “yyyy-MM-dd HH:mm:ss zzz” and using the cellsFormat to specify the format, but it did not work. Can you help?
Hi lil,
formatdate requires JavaScript Date Object, not a String.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOur datasource comes from a network request which is translated into a json string. It is the same for both browsers. Here are the column properties:
dataType = "date"; dataFormat = "yyyy-MM-dd HH:mm:ss zzz"; cellsFormat = "MMM dd HH:mm:ss, yyyy"; cellsRenderer = startDateStampCellRenderer;
Why would the ‘value’ parameter in the startDateStampCellRenderer be a date in Chrome but a string in Internet Explorer?
Hi lil,
Chrome’s JavaScript date object may be able to parse your String. In other browser it may not be. So, you should use Javascript Date objects always. formatDate expects a JavaScript Date Object, not String and formatDate called within cellsrenderer by you has no relationship to your Column Settings. You have overriden them by setting the cellsrenderer property. Also the properties in jqxGrid are low case and it is case sensitive. To learn how to use jqxGrid and bind it to data sources which have Dates, please take a look at: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-datasources.htm
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.