答案 0 :(得分:1)
使用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示例应用程序。它可以通过NatTable homepage作为WebStart应用程序使用。或者,如果WebStart不起作用,您可以下载示例jar文件并从command line执行它。
要查看的示例位于教程示例 - >&gt;图层 - &gt;选择 - &gt; RowSelectionExample