Search code examples
javagwtgxt

GXT strange behavior with GridInlineEditing


I use GXT 3.0.5 (commercial license).

When I create a grid with a GridInlineEditing, I have some weird bug on Chrome only :

  • With setCLicksToEdit(ONE), the columns cannot be edited (the edition component appears then disappears immediatly)
  • With setCLicksToEdit(TWO), I can edit all columns except the ones containing a CheckBox : The CheckBox appears but when I click on it, the edition finishes and the value is not updated.

I created a small example with a Grid which display several times this Bean :

public class MyBean {

  private Integer id;
  private String label;
  private Boolean enabled;

  public MyBean(Integer id, String label, Boolean enabled) {
    this.id = id;
    this.label = label;
    this.enabled = enabled;
  }

  //Getters & Setters
}

And the corresponding grid. I made it as simple as possible :

public class MyGrid extends Composite {

  public interface MyPropertyAccess extends PropertyAccess<MyBean> {
    ValueProvider<MyBean, Integer> id();
    ValueProvider<MyBean, String> label();
    ValueProvider<MyBean, Boolean> enabled();
  }


  public MyGrid(){

    //Build columnModel
    MyPropertyAccess propertyAccess = GWT.create(MyPropertyAccess.class);
    ColumnConfig<MyBean, Integer> colId      =  new ColumnConfig<MyBean, Integer>(propertyAccess.id(),500, "ID");
    ColumnConfig<MyBean, String>  colLabel   = new ColumnConfig<MyBean, String>(propertyAccess.label(), 500, "Label");
    ColumnConfig<MyBean, Boolean> colEnabled = new ColumnConfig<MyBean, Boolean>(propertyAccess.enabled(), 500, "Enabled");
    ColumnModel<MyBean> columnModel = new ColumnModel<MyBean>(Arrays.<ColumnConfig<MyBean,?>>asList(colId, colLabel, colEnabled));

    //Create grid
    Grid<MyBean> grid = new Grid<MyBean>(new ListStore<MyBean>(buildModelKeyProvider()), columnModel);

    //Make it editable
    GridInlineEditing<MyBean> inlineEditing = new GridInlineEditing<MyBean>(grid);
    inlineEditing.addEditor(colLabel, new TextField());
    inlineEditing.addEditor(colEnabled, new CheckBox());
    inlineEditing.setClicksToEdit(ClicksToEdit.TWO);

    //Fill store with dummy values
    for(int i = 1;i<=30;i++){
      grid.getStore().add(new MyBean(i, "Bean"+i, i%2==0));
    }

    this.initWidget(grid);
  }

  private ModelKeyProvider<MyBean> buildModelKeyProvider(){
    return new ModelKeyProvider<MyBean>() {
      @Override
      public String getKey(MyBean item) {
        return Integer.toString(item.getId());
      }
    };
  }

}

Do I do something wrong or is there a bug in GXT?

Note : I can replace the GridInlineEditing with a GridRowEditing (it works) but this doesn't meet the users need anymore.

Note : On firefox, I have the same problem with setCLicksToEdit(ONE) but everything is fine with setCLicksToEdit(TWO)


Solution

  • Check this out http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/row-editing.html It's a newer GXT version but you can see checkboxes don't update when you commit changes. It seems to be a bug in GXT.

    And this one could help you with the first issue: http://www.sencha.com/forum/showthread.php?266458-GridInlineEditing-fires-blur-event-immediately-after-cliking