Announcement

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

    BUG REPORT: ListGrid not correctly applying DataSourceDateField format

    In the example below the validation of the field fails even though the format on the date field is set correctly.

    Have we missed something on the DataSourceDateField setup or we stumbled upon a bug?


    Click image for larger version

Name:	upload.png
Views:	121
Size:	7.1 KB
ID:	257604


    Code:
    private static final ListGridRecord[] RECORDS = { mkRecord(1, "test"), mkRecord(0, "test2"), mkRecord(2, "test2"), mkRecord(4, "test4") };
    
    @Override
    public void onModuleLoad()
    {
        VLayout layout = new VLayout();
        RootPanel.get().add(layout);
    
        DataSource dataSource = new DataSource();
        dataSource.setClientOnly(true);
        dataSource.setTestData(RECORDS);
        DataSourceField sequenceField = new DataSourceSequenceField("id", "ID");
        sequenceField.setRequired(true);
        DataSourceField textField = new DataSourceTextField("textField", "Text Field");
        DataSourceField dateField = new DataSourceDateField("dateField", "Date Field");
        dateField.setFormat("dd/MM/yyyy");
        dataSource.setFields(sequenceField, textField, dateField);
    
        ListGrid listGrid = new ListGrid(dataSource);
        listGrid.setSize("500", "200");
        listGrid.setCanEdit(true);
        listGrid.setAutoFetchData(true);
        layout.addMember(listGrid);
    
        Button button = new Button("add");
        button.addClickHandler(h -> listGrid.startEditingNew());
        layout.addMember(button);
    }
    
    private static final ListGridRecord mkRecord(int id, String textField)
    {
        final ListGridRecord record = new ListGridRecord();
        record.setAttribute("id", id);
        record.setAttribute("textField", textField);
        return record;
    }

    #2
    Looks like you have set a display format but not set the input format to match. This is required, otherwise the expected input format is still whatever is set in your locale, or has been set globally.

    Note that typically you would just set input format globally via DateUtil, rather than repeating it on every date field. Use the latter approach only in the rare case that you need different input formats in different components.

    Comment


      #3
      Thank you for the DateUtils hint, this will help us making a global fix, rather than having to set this up in each single column

      Comment

      Working...
      X