I found one interesting solution, but unfortunately not perfect.
To prevent deselect row we could write a SelectionListener
and put there some logic:
grid.setSelectionMode(Grid.SelectionMode.SINGLE);
grid.addSelectionListener(event -> {
Set<Object> selected = event.getSelected();
if (selected == null || selected.isEmpty()) {
Set<Object> removed = event.getRemoved();
removed.stream().filter(Objects::nonNull).forEach(someGrid::select);
}
});
So assuming single selection mode, if current selection is empty, then previous selected row should be selected again. But if current selection isn't empty it means that somebody select another row - this doesn't require any action.
It is cool but not enough - every click (selection) cause http call and network transmission. This is disadvantage.