0

I manually delete the selected rows in the grid using:

for(Object selectedItem: grid.getSelectedRows())
    grid.getContainerDataSource().removeItem(selectedItem);

grid.getSelectionModel().reset();

According to the Vaadin documentation you need to call reset() on the selectionModel so that they are in sync, and that's great.

This all works great but only if I scroll down the grid with the mouse in the browser, so that the whole grid moves. If I don't scroll the grid in my browser then the mouse selects the wrong row by the exact number of rows that were previously selected before that row. So if I select row 2 and then delete it, then select row 3 it will in fact select row 4. If however I scroll down so that the grid view is refreshed then everything works exactly as expected and the correct row is selected.

Using Vaadin 7.7.5.

Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

1 Answers1

0

Looks like it is difficult to get the grid to refresh.

grid.clearSortOrder();

Seems to be the current workaround.

Community
  • 1
  • 1
Reto Höhener
  • 5,419
  • 4
  • 39
  • 79
  • Unfortunately it doesn't really work. Yes it does resolve the issue in that you can correctly select from the grid the problem is that if you setup filters on the columns then it fails and results in the same bug. – Stephane Grenier Dec 17 '16 at 20:58