jQWidgets Forums

jQuery UI Widgets Forums Grid Date off by One Day

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Date off by One Day #26505

    aoverton07
    Participant

    I was having trouble getting my grid to show the correct date it was showing “2013-8-11” instead of “2013-8-12” . I fixed my problem by defining the datafield as a date and then defining the cellsformat to “yyyy-MM-dd”. it appeared that everything was fixed, then when I try to apply an external filter to the grid (by redefining the source) it goes back to its old ways of showing the incorrect date…

    define datafield in source:

    { name: 'week_start', type: 'date' }

    define column in grid init:

    { text: "Week Start" , datafield: "week_start", columntype: 'datetimeinput', cellsformat: "yyyy-MM-dd", filtertype: 'date', width: 100 }

    JSON returned: “2013-8-12”

    Date shown: “2013-8-12” (YAYYY it’s working)

    NOW, when i redefine source AND columns:

    JSON returned: “2013-8-12”

    Date shown: “2013-8-11” (WHY THE HECK is it doing this? I’ve followed all the same steps as in the grid init….)

    Date off by One Day #26506

    Peter Stoev
    Keymaster

    Hi aoverton07,

    For such strange formats, you should define the format member in the datafield, too. i.e format: “yyyy-MM-dd”.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Date off by One Day #26509

    aoverton07
    Participant

    Thank you Peter, this fixed my problem. It’s just strange how it works on grid init, but not on redefining datafields and columns.

    Date off by One Day #26510

    Peter Stoev
    Keymaster

    Hi aoverton07,

    Unless you set explicit Data source format while you initialize the Grid, the Grid will try to parse your String to a JavaScript Date object by passing your String to the JavaScript Date object’s constructor. Then the formatted text(formatting is done by cellsformat) is what is displayed in the cells.

    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.