【问题标题】:How to config NatTable to select entire row not single?如何配置 NatTable 以选择整行而不是单行?
【发布时间】:2016-11-29 22:34:12
【问题描述】:

我使用 NatTable 创建表。

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

如下

【问题讨论】:

  • 请显示您当前配置的代码

标签: row nattable


【解决方案1】:

使用RowSelectionModel。以下 sn-p 摘自 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 执行。

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

【讨论】:

    猜你喜欢
    • 2020-02-18
    • 2015-07-08
    • 2016-09-21
    • 1970-01-01
    • 2011-10-10
    • 2016-11-03
    • 2014-08-29
    • 1970-01-01
    • 2011-09-21
    相关资源
    最近更新 更多