RE: Grid Get Focused Row Bean

So you want to get an event when a row is selected? SelectionListener is probably better because it should work with all ways that you can select a row - by clicking, by keyboard, programmatically.

grid.addSelectionListener(event -> {
  Set<Person> selected = event.getAllSelectedItems();
  Notification.show(selected.size() + " items selected");
});

Did I understand correctly that you have some kind of components in your grid, and if you click on the component, the row does not get selected? And you want it to select the row? Usually components eat the click events so that you can interact with the components. What components are you using?

Grid has methods to get selected item as described by Jens.

If you need to get the focused item, you need to use GridFastNavigation add-on and its focust tracker events https://vaadin.com/directory/component/gridfastnavigation-add-on

Hi,

I have a question about Grid component. In my example a grid instance has component columns. I try first, item click listener to get focused bean. But the listener works for noncomponent colums.

grid.addItemClickListener(e -> currentLine = e.getItem());

Is there any way to get focused grid row bean? What is the best way to get focused grid row?

Thanks for answer. I use Combobox and TextField in grid columns. Selection mode for my grid is NONE, so i can’t add selection listener.

Thanks for answer. But is there an alternative solution to handle the problem without using any add-on?

At the moment using that add-on is clearly the easiest option. When you look into source code of it, you will notice that it is not trivial.