jQWidgets Forums

jQuery UI Widgets Forums Grid formatDate not working in IE11 when String is passed

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • lil
    Participant

    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?


    Peter Stoev
    Keymaster

    Hi lil,

    formatdate requires JavaScript Date Object, not a String.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    lil
    Participant

    Our 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?


    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.