如何在CellTable中完全禁用行选择?

cqc*_*law 4 java gwt

我希望在CellTable中选择行时完全查看更新.如何才能做到这一点?在以下测试用例中,使用NoSelectionModel,视图仍然更新:单击一行会更改行的背景和边框颜色,直到单击另一行.

    CellTable<String> table = new CellTable<String>();

    TextColumn<String> column = new TextColumn<String>()
    {
        @Override
        public String getValue(String string)
        {
            return string;
        }
    };

    table.addColumn(column);

    List<String> sampleData = Arrays.asList("foo", "bar", "baz");

    table.setRowData(sampleData);

    final NoSelectionModel<String> selectionModel = new NoSelectionModel<String>();
    table.setSelectionModel(selectionModel);

    RootPanel.get().add(table);
Run Code Online (Sandbox Code Playgroud)

我还尝试使用空覆盖方法对SingleSelectionModel进行子类化,但没有成功.

我可以通过为选定的行提供空的CSS样式来伪造我想要的行为,但是这种方法看起来很糟糕.

Tho*_*yer 13

您所看到的是键盘选择突出显示(当您不使用鼠标与表进行交互时非常有用).
你可以使用它来禁用它setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED)