我使用 NatTable 创建表。
但我不知道如何配置它以应用于选择整行而不是单行。
使用RowSelectionModel
. 以下片段摘自_5052_RowSelectionExample
NatTable 示例。
// 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 示例应用程序。它可以通过NatTable 主页作为 WebStart 应用程序使用。或者,如果 WebStart 不起作用,您可以下载示例 jar 文件并从命令行执行它。
要查看的示例位于Tutorial Examples -> Layers -> Selection -> RowSelectionExample 下