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