Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I completely disable row selection in a CellTable?

Tags:

java

gwt

I want to completely view updates when a row is selected in a CellTable. How can this be done? In the following test case, using NoSelectionModel, the view is still updated: clicking on a row changes the background and border colors of the row until another row is clicked.

    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);

I've also attempted to subclass SingleSelectionModel with empty override methods, without success.

I can fake the behavior I want by providing empty CSS stylings for selected rows, but that method seems hack-ish.

like image 767
cqcallaw Avatar asked Dec 13 '22 02:12

cqcallaw


1 Answers

What you're seeing is the keyboard-selection highlighting (really useful when you're not using the mouse to interact with the table).
You can disable it using setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED)

like image 109
Thomas Broyer Avatar answered Dec 27 '22 21:12

Thomas Broyer