Announcement

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

    BUG REPORT: DataSource.recordsAsText() does not respect column date and time format

    Running the code below you will see the date shown on the grid as "02/2019" and in the alert as "02/27/2019 12:22".

    I expected the datasouce to use the field information in order to correctly convert the data to text.

    We are running "Version v12.0p_2019-02-20/Enterprise Deployment (2019-02-20)"

    Code:
    DataSource dataSource = new DataSource();
    dataSource.setUseOfflineStorage(true);
    DataSourceField dateTimeField = new DataSourceField("dateTime", FieldType.DATETIME);
    dateTimeField.setFormat("MM/YYYY");
    dataSource.setFields(dateTimeField);
    
    Record record = new Record();
    record.setAttribute("dateTime", new Date());
    Record[] records = new Record[] { record };
    
    ListGrid listGrid = new ListGrid(dataSource);
    listGrid.setData(records);
    listGrid.draw();
    
    Window.alert(dataSource.recordsAsText(records));

    #2
    This API is neither designed nor documented to do this, so this is not a bug.

    You can set a single date and datetime format via the optional TextExportSettings parameter - the default is what Excel and other common consumers of CSV will recognize as dates.

    Comment

    Working...
    X