我希望在更改另一个值后立即更新网格编辑器中正在编辑的行。因此,例如,如果我在购买中更改货币,我希望为该货币调整金额。考虑到这一点,我有:
Grid grid = new Grid();
grid.getEditor().setEnabled(true);
grid.addColumn(Purchase::getAmount())
.setEditorBinding(amountField, Purchase::setAmount);
grid.addColumn(Purchase::getCurrency())
.setEditorBinding(currencyField, Purchase::setCurrency);
grid.getEditor().getBinder().addValueChangeListener(event ->
{
Component component = event.getComponent();
if(component.equals(currencyField))
{
Purchase purchase = binder.getBean();
purchase.setAmount(amountAdjustedForCurrency(purchase.getCurrency()));
// How do I update to the amount in the grid for that row?
}
});
我的问题是如何更新网格中的金额?即使已经调整了bean,屏幕也没有更新......
答案 0 :(得分:0)
我想到的第一件事就是编程强制关闭 - 在值变更监听器中重新打开编辑。
grid.getEditor()保存(); 。grid.getEditor()editRow(rowIndex位置);