如何更新;“总价”;更改其他列时的列值“;数量;GWT中每行的datagrid中的值?

如何更新;“总价”;更改其他列时的列值“;数量;GWT中每行的datagrid中的值?,gwt,datagrid,Gwt,Datagrid,我有一个带有5列的DataGrid表,如下所示: | | | qty | id | desc | price/unit | (editable field) | total price ---+---------+------------+------------------+------------ 1 | my id 1 | 10 | 1 | 10

我有一个带有5列的
DataGrid
表,如下所示:

   |         |            |              qty | 
id | desc    | price/unit | (editable field) | total price
---+---------+------------+------------------+------------
 1 | my id 1 |         10 |                1 |         10
 2 | my id 2 |         20 |                2 |         40
 3 | my id 3 |         30 |                3 |         90
 4 | my id 4 |         40 |                4 |        160
这里我需要的是,如果我正在将第1行的
数量
值从1更新到10,那么它应该将第1行的
总价
更新到100。如何实现这一点?

在可编辑列的中,您有
update
方法。此方法在其第一个参数中获取
rowIndex
。这是您需要重新绘制以刷新
total price
列的行。当然,我假设
totall price
是基于当前
qty
price
值计算的

像这样:

qtyColumn.setFieldUpdater(new FieldUpdater<RowType, String>() {
    @Override
    public void update(int index, RowType object, String value) {

        ...

        object.setQty(newValue);
        grid.redrawRow(index);
    }
});
qtyColumn.setFieldUpdater(新的FieldUpdater(){
@凌驾
公共void更新(int索引、RowType对象、字符串值){
...
object.setQty(newValue);
网格。重绘行(索引);
}
});