jQWidgets Forums

jQuery UI Widgets Forums Grid Date/time formatting in grid

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 5 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Date/time formatting in grid #108236

    robf
    Participant

    I know this question has been asked many times before but still cannot get a firm answer.

    I am getting data from a Mongo database which only stores dates as datetime – e.g. ISODate(“2019-03-15T00:00:00.000Z”)

    For my cellrender I define:

    {
    text: "My Date",
    dataField: "myDate",
    cellsrenderer: dateRenderer,
    cellsformat: 'MM/dd/yyyy',
    cellsalign: "center",
    width: 130
    },

    Cellrender function takes data and converts to moment utc:
    function dateRenderer(row, columnfield, value)
    {
    var myDate = value ? moment.utc(value).format(‘MM/DD/YYYY’) : “”;
    var cssclass = “jqCell jqx-grid-cell-middle-align ”
    return ‘<div class=”‘ + cssclass + ‘”>’ + myDate + ‘</div>’;
    }

    The cell column renders fine. However when I GROUP on the column the date is one-day off – i.e. not honoring the date in the cell.
    So the cell would correctly 03/15/2019 but the GROUPING label shows 03/14/2019.

    I am unsure how to make this consistent.

    Can you please provide guidance on this?

    Thanks.
    Rob

    Date/time formatting in grid #108289

    Peter Stoev
    Keymaster

    Hi Rob,

    Please, refer to https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-datasources.htm, where it is written about Example: { name: ‘SubmitDate’, type: ‘date’, format: “yyyy-MM-ddTHH:mm:ss-HH:mm” }

    Regards,
    Peter

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

You must be logged in to reply to this topic.