1

I'd like to be able to navigate around a grid in Vaadin 14 (or higher) with only Keyboard shortcuts. It's possible to select a single cell in the grid, but then it's only visually selected and i can't find out which one is currently selected through code. I found this question here: How to navigate through Vaadin grid and select an item using keyboard?

This would solve my problem but this Add-on is for Vaadin 8 and doesn't work with version 14.

Is there either any way to find out which cell is currently selected (on another button press) or is there any other Add-on i haven't found, which does basically the same but for Vaadin 14?

Salo
  • 11
  • 2

1 Answers1

0

Edit:
I did not understand at first that you are in fact not yet properly selecting an item, instead it probably only shifts the focus around.
I believe you can select the focused row by pressing space key. I tested it over here and seems to work out of the box.
For GridMultiSelectionModel it looks like you need to have the focus on the selection column.

You can define your own shortcut if space is not what you want. However, in that case I don't know the answer to "how do you find out which row is currently focused?". maybe something along the lines of this? (no guarantees)

UI.getCurrent().addShortcutListener((event) -> grid.select(event.getSource()), Key.ENTER);
kscherrer
  • 5,486
  • 2
  • 19
  • 59
  • Sorry if the question wasn't clear enough. Yes, you are right the focus is shifting around and when I then press space, i can read out at which row I'm currently at. But I don't want to press space every time i shifted around. Another way to ask this questions is: How can I automatically select the current row where the user shifted to. Is there a way to press the space key automatically (programatically)? – Salo Jun 27 '20 at 13:52
  • With shifting I mean shifting the `focus` around. – Salo Jun 27 '20 at 13:59