GWT:如何使用 SelectionModel 检查 CellTable 的选择事件

GWT: how to check the selection event for a CellTable with a SelectionModel

我们使用具有两列和 SingleSelectionModel 的可排序 CellTable。 现在其中一列充满了 ButtonCells。

问题是:如果我第一次直接单击某行的按钮,只会选中该行,而不会直接触发该按钮的事件。我必须点击第二次。

我该如何更改?如何直接触发按钮事件?

您可以在按钮列上设置 FieldUpdater:

column.setFieldUpdater(new FieldUpdater<Auction, String>() {
  @Override
  public void update(int index, Auction object, String value) {
    // The user clicked on the button for the passed auction.
  }
});

GWT 文档中的 CellSampler 有一个可点击按钮的直接示例。干杯。

另一种选择是覆盖 Button 的 onBrowserEvent() 方法。