如何更新GWT中每行数据网格中其他列“qty”值更改的“总价格”列值?

问题描述 投票:0回答:1

我有一个带有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行的qty值从1更新为10,那么它应该将第1行的total price更新为100.如何实现此目的?

gwt datagrid
1个回答
1
投票

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

像这样:

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

        ...

        object.setQty(newValue);
        grid.redrawRow(index);
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.