Grid - Items not deselected after removing


  1. Multi selectable grid bound to a container
  2. Delete button, that when pressed removes selected items from the container, i.e. calls container.removeItem(itemId)

So far so good - Delete button is pressed and selected items are removed from container and visually disappears from the grid.

Problem - unfortunatelly next selection of a row in the grid trows an exception because probably grid did not cleaned up already delete items from the selection model. If I do a programatic grid.deselect(itemThatIsGoingToBeDeletedId) before calling container.removeItem(itemId) everything works fine.

Best Regards

Seems like a bug, I’ve
a ticket about this.

Which is a duplicate of
:slight_smile: Was supposed to be fixed already in 7.4.0 but turned out it’s pretty unfeasible to implement efficiently in the general case. Table and other AbstractSelects had the same issue, and it was resolved by adding an explicit “sanitizeSelection” method that can be manually invoked when required.

The underlying problem is that most containers don’t know how to signal “These items were removed”, only that “Some items were added or removed”, and checking whether each selected item still exists in the container might be prohibitively expensive in case of DB-backed containers, for instance.