Search code examples
gxt

GXT 2.2.4 grid row editor


I'm working on a 3 years old GXT project. I have an editable grid, I want while editing one cell, say cell A, another cell, say cell B, of the same row update it's value. In fact cell B must represent some computation based on cell A's field value. Here is the code I use to catch changes on cell A' field:

cellAField.addKeyListener(new KeyListener() {
    @Override
        public void componentKeyUp(ComponentEvent event) {
            try {
                computeValueOfCellB(cellAField.getValue().doubleValue());
            } catch (Throwable e) {
                Log.warn(e.getMessage());
            }
        }
});

and here is what I do to compute and update cell B value:

private void computeValueOfCellB(Double value_of_A) {
    BeanModel bean = grid.getSelectionModel().getSelectedItem();
    bean.set("cell_A", value_of_A);
    bean.set("cell_B", value_of_A - someDoubleValue);
    grid.getStore().update(bean);
}

Well as I update the store with the new bean, value of cell B is not showed in the grid's row editor, to show cell B's value I must call a grid.getView().refresh(false); to see cell B'value changing as I change value of cell A. Is there a way to achieve this without redrawing the entire grid? When I update the store, grid should show the new values doesn't it? I'm using GXT 2.2.4.


Solution

  • You are right. You will have to explicitly call refresh(). If you want to avoid the call to refresh() you will have to set the auto-commit flag in the gridstore to true.

    gridObj.getStore().setAutoCommit(true);