jQWidgets Forums

jQuery UI Widgets Forums Grid Grid changing dates

Tagged: 

This topic contains 6 replies, has 4 voices, and was last updated by  Peter Stoev 12 years, 6 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Grid changing dates #6627

    JeffMcNees
    Member

    I have a grid with a date column in it.  I send it a date that I want displayed but the grid keeps trying to localize the time.  How do I stop the grid from trying to localize the time and just display it while keeping the formatting and filters set to a date?

    Grid changing dates #6630

    BHansen
    Member

    I am also having this problem. Anyone have any ideas?

    Grid changing dates #6633

    Peter Stoev
    Keymaster

    If you display your Date as a string and you don’t set the type of the datafield to date, the Grid will not try to parse your string to a Date and will not try to format your date. It will treat that column as a String column. Formatting and Filters for a Date column work with Date objects which according to me is a correct behavior. For localization and custom cells rendering see here: jquery-grid-cellsrendering.htm and jquery-grid-localization.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Grid changing dates #6635

    JeffMcNees
    Member

    I agree that if we set the column to a string it will display correctly. The problem is that the date I am sending back is just a date and time which means the browser interprets it as GMT. Something is converting that date to a local date on the client side. I don’t want that to happen. If I set the column to a string I get the wrong filters. I need to keep the date filters but display the date exactly as I sent it to the browser. Does that make sense? Is there a way to do that?

    Grid changing dates #6636

    JeffMcNees
    Member

    Nevermind. It was a problem with a virtual running on a server with different time zones set. Thanks for your support!

    Grid changing dates #11078

    kcrusch
    Participant

    Yeah, I’m running into this as well. When you say
    “If you display your Date as a string and you don’t set the type of the datafield to date….”

    are you implying that any time we use a date column and want it formatted as a date (such as “MM/dd/yyyy”) that we are *forced* to allow it to adjust for GMT as well?

    Grid changing dates #11080

    Peter Stoev
    Keymaster

    Hi kcrusch,

    If you have a Date column with Javascript Date values and you want the Grid to format that date values using a specific format string, make sure you set the datafield’s type field to ‘date’. This will ensure that Filtering, Sorting, etc will work as expected for that Date Column. If you want to display the date as you receive it from your data source, without formatting, don’t set the column’s cellsformat property. Another option is to display your Date values as String by setting the datafield’s type to string. However, sorting and filtering will assume that the column cells values are strings, not dates. For more information about using Dates and Formatting Dates, please take a look at the help topic: jquery-grid-datasources.htm and also at the Grid’s API, especially the documentation about the column’s property and the column’s cellsformat field.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.