【问题标题】:How to force an update in a Vaadin Grid after a valueChange through the Grid Editor?如何通过网格编辑器在 valueChange 后强制更新 Vaadin 网格?
【发布时间】:2018-03-25 05:45:39
【问题描述】:

我想在另一个值发生更改后立即更新网格编辑器中正在编辑的行中的 a。因此,例如,如果我在购买时更改货币,我希望针对该货币调整金额。考虑到这一点,我有:

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 已调整,屏幕也不会更新...

【问题讨论】:

    标签: java vaadin vaadin8 vaadin-grid


    【解决方案1】:

    我想到的第一件事是执行程序化强制关闭 - 在该值更改侦听器中编辑重新打开。

    grid.getEditor().save(); grid.getEditor().editRow(rowIndex);

    【讨论】:

      猜你喜欢
      • 2017-07-18
      • 1970-01-01
      • 2014-03-18
      • 2019-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多