Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    setDateFormatter() in grid has no effect

    Hi,

    I'm using a datasource-bound listGrid to show data from a MS SQL database in a remote server. One of the ListGridField's is showing datetime data, currently in the form

    2013-01-24T12:03:34.623+0000

    I want to make this format more readable, so I want to how it in format "dd/mm/yyyy hh:mm:ss".

    In the listGrid's datasource, the relevant field is of type DataSourceDateTimeField. I'm also doing this to the ListGridField:

    dateField.setType(ListGridFieldType.DATETIME);

    So that SmartGWT knows for sure this is a DateTime we're talking about.

    Now, to set the column to my intended format, I've tried three things:

    1. Setting a system-wide format with DateUtils.setShortDateTimeFormat (also tried with Normal instead of Short).

    2. Setting the whole ListGrid's date format with

    operations.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE);

    3. Setting the ListGridField's date format with

    dateField.setDateFormatter(DateDisplayFormat.TOSERIALIZEABLEDATE);

    None of these worked; the format is still the original one.

    SmartGWT version: 3.1
    SmartClient version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)
    Browsers: IE9, Chrome 24.0.1312.56 m

    Thank you very much in advance.

    #2
    The problem is that the value for the field is a String and not an actual Date instance.

    If you are using the Server Framework, the values provided inside dsResponse.data should be actual Java Date instances.

    For REST, see the docs for RestDataSource and field.type "datetime".

    Comment

    Working...
    X