Announcement

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

    ListGrid setEditValue does not work on DATE/DATETIME fields that are not visible

    Hi,

    Setting the edit value of a DATE or DATETIME field does not work when the field is not currently visible in the ListGrid.
    It does always work for other field types, for DATE and DATETIME fields it only works when the field is visible.
    I would expect the behavior of setEditValue on fields that are not visible to be the same for all field types.

    Context:
    SmartClient Version: v12.1p_2020-12-02/LGPL Development Only (built 2020-12-02)
    GWT Version: 2.9.0
    Tested in Super Dev mode and compiled mode.
    Behavior is the same across the following browsers:
    Chrome - 87.0.4280.66
    Firefox - 82.0.3
    Edge

    Test case:
    A grid is created with a client-only datasource that contains one record with default values for fields of types DATE, DATETIME, INTEGER, and TEXT.
    A button is added that sets the edit values of all 4 fields.

    Steps taken:
    1. Use the grid header context menu to hide all columns except the PK field.
    2. Click the 'setEditValue' button at the bottom of the page.
    3. Use the grid header context menu to make all columns visible again.
    4. The edit values of the INTEGER and TEXT fields have been correctly set, the edit values of the DATE and DATETIME fields have not been set.

    Code:
    public class TestEntryPoint extends SmartGwtEntryPoint
    {
       @Override
       public void onModuleLoad()
       {
          DataSource dataSource = new DataSource();
          dataSource.setClientOnly(true);
          DataSourceField idField = new DataSourceField("id", FieldType.INTEGER, "PK");
          idField.setPrimaryKey(true);
          DataSourceField datetimeField = new DataSourceField("datetime", FieldType.DATETIME, "Datetime");
          DataSourceField dateField = new DataSourceField("date", FieldType.DATE, "Date");
          DataSourceField intField = new DataSourceField("int", FieldType.INTEGER, "Integer");
          DataSourceField textField = new DataSourceField("text", FieldType.TEXT, "Text");
          dataSource.setFields(idField, datetimeField, dateField, intField, textField);
    
          ListGridRecord[] testData = new ListGridRecord[1];
          testData[0] = new ListGridRecord();
          testData[0].setAttribute("id", 0);
          testData[0].setAttribute("datetime", new Date(0));
          testData[0].setAttribute("date", new Date(0));
          testData[0].setAttribute("int", 0);
          testData[0].setAttribute("text", "original");
          dataSource.setCacheData(testData);
    
          ListGrid grid = new ListGrid();
          grid.setDataSource(dataSource);
          grid.fetchData();
    
          Button testButton = new Button("setEditValue");
          testButton.addClickHandler((event) ->
          {
             grid.setEditValue(0, "datetime", new Date());
             grid.setEditValue(0, "date", new Date());
             grid.setEditValue(0, "int", 1);
             grid.setEditValue(0, "text", "modified");
          });
    
          VLayout layout = new VLayout();
          layout.setWidth100();
          layout.setHeight100();
          layout.setMembers(grid, testButton);
          layout.draw();
       }
    }

    #2
    How are you determining that the edit values are not applied?

    The date you're applying is the same as the value the field already has, so would be ignored.

    The datetime value might differ by little enough that it wouldn't affect display.

    Also, be sure to read the Date & Time Storage overview as you are creating date and time values incorrectly (read about logical dates).

    Comment


      #3
      Thanks for your quick response.
      I first determined that the edit values were not applied by looking at the values shown in the grid for the modified record.
      The date that is applied is different from the initial date by a lot, note that the initial value is
      Code:
      new Date(0)
      and not
      Code:
      new Date()
      .
      So if I click the button while the columns are visible I see the date change from somewhere in 1970 to somewhere in 2020.

      I also just checked what ListGrid.getEditValue returned for the columns.
      For the DATE and DATETIME columns getEditValue returns null in the case the edit value was set while the field was not visible. For the other fields it returned the same value as was provided in setEditValue.

      Thanks for the tip on logical dates, I'll make sure to read up on those.

      Comment


        #4
        Thanks for the additional information
        We've made a change which should resolve this issue - please try the next nightly build, dated December 4. The change has been made in the 12.1 and 13.0d branches

        Regards
        Isomorphic Software

        Comment

        Working...
        X