@Override public void dataGridSourceItemSetChanged(DataGridItems.ItemSetChangeEvent<E> event) { // #PL-2035, reload selection from ds Set<E> selectedItems = getSelected(); Set<E> newSelection = new HashSet<>(); for (E item : selectedItems) { if (event.getSource().containsItem(item)) { newSelection.add(event.getSource().getItem(item.getId())); } } if (event.getSource().getState() == BindingState.ACTIVE && event.getSource().getSelectedItem() != null) { newSelection.add(event.getSource().getSelectedItem()); } if (newSelection.isEmpty()) { setSelected((E) null); } else { // Workaround for the MultiSelect model. // Set the selected items only if the previous selection is different // Otherwise, the DataGrid rows will display the values before editing if (isMultiSelect() && !selectedItems.equals(newSelection)) { setSelectedItems(newSelection); } } refreshActionsState(); }
protected void datasourceCollectionChanged(@SuppressWarnings("unused") CollectionDatasource.CollectionChangeEvent<E, K> e) { events.publish(ItemSetChangeEvent.class, new ItemSetChangeEvent<>(this)); }
protected void containerCollectionChanged(@SuppressWarnings("unused") CollectionContainer.CollectionChangeEvent<E> e) { events.publish(DataGridItems.ItemSetChangeEvent.class, new DataGridItems.ItemSetChangeEvent<>(this)); }