Add standard selection behavior to tables

As Vaadin strives to look and feel like a desktop application, I think users should be able to work with a selectable table with multi-select as they know it from desktop applications:

  • Ctrl-A should select all rows
  • Ctrl and click on row should add/remove the row to/from the current selection
  • range selection with shift
  • deselect everything if the user clicks outside the table (I guess that’s debatable)

Is this already there and I just don’t find it or would I have to create a feature request?

I already tried to add the first requirement with a
but since shortcuts are fundamentally broken in Vaadin because they affect the whole site and not the component they are attached to, I cannot combine this with fields. It is very surprising to be in a text field and have a Ctrl-A suddenly select all rows of the table. Since a table is not
, I cannot even hack around it.

Hi Werner,

please check
the following points already are implemented in table:

  • Ctrl and click on row should add/remove the row to/from the current selection
  • range selection with shift

You have to set your table to multi selection, setMultiSelect(true), and the multi selection mode to DEFAULT, setMultiSelectMode(MultiSelectMode.DEFAULT). The MultiSelectMode.SIMPLE does not provde SHIFT- and CTRL- functionalities but simply adds/removes item selection on clicking on items.

The CTRL-A to select a you could handle with ShortcutListener (beware of focus!). The deselect everything will be a little bit heavier to implement.

Because table implements the interface Field, you could try using the
- and
But I would not recommend to auto deselect.

Thanks for your answer.

I must’ve mixed something up. Indeed, shift and ctrl select works as it should.

Regarding the
I made a mistake.
but does not implement
which is needed to get focus events. So adding a
on demand is impossible. I think I’ll add an edit menu with appropriate menu items.


i have some problems with shortcuts on different operating system.

I created a shortcut to select all rows, which works on Windows, but not on Mac, because mac user will use CMD as modifier.

new ShortcutAction("Select All", ShortcutAction.KeyCode.A,
+ new int[] { ShortcutAction.ModifierKey.CTRL });

Is there a solution?