如何将 NatTable 配置为 select 整行而不是单个?

How to config NatTable to select entire row not single?

我使用 NatTable 创建了 table。

但我不知道如何配置它以应用于 select 整行而不是单个行。

如下

使用RowSelectionModel。以下片段摘自 NatTable 示例的 _5052_RowSelectionExample

// use a RowSelectionModel that will perform row selections and is able
// to identify a row via unique ID
selectionLayer.setSelectionModel(new RowSelectionModel<Person>(
selectionLayer, bodyDataProvider, new IRowIdAccessor<Person>() {

    @Override
    public Serializable getRowId(Person rowObject) {
        return rowObject.getId();
    }

}));

// register the DefaultRowSelectionLayerConfiguration that contains the
// default styling and functionality bindings (search, tick update)
// and different configurations for a move command handler that always
// moves by a row and row only selection bindings
selectionLayer.addConfiguration(new DefaultRowSelectionLayerConfiguration());

了解 NatTable 的最佳方式是查看 NatTable 示例应用程序。如果 WebStart 不起作用,它可以通过 NatTable homepage. Or you can download the examples jar file and execute it from command line 作为 WebStart 应用程序使用。

要查看的示例位于 Tutorial Examples -> Layers -> Selection -> RowSelectionExample