-
Notifications
You must be signed in to change notification settings - Fork 185
Closed
Description
Describe your motivation
I would like an easy access to replace my items in the AbstractListDataView.
Describe the solution you'd like
I would like this method:
@Override
public AbstractListDataView<T> setItems(Collection<T> items) {
Objects.requireNonNull(items, NULL_COLLECTION_ERROR_MESSAGE);
final ListDataProvider<T> dataProvider = getDataProvider();
dataProvider.getItems().clear();
dataProvider.getItems().addAll(items);
dataProvider.refreshAll();
return this;
}
Describe alternatives you've considered
First I wanted to do:
grid.setItems(items);
But you are losing all the listener on the dataprovider/dataview.
I also tried:
GridListDataView<XX> dataView = subsidyRequestGrid.setItems(dataProvider);
...
dataView.removeItems(oldItems);
dataView.addItems(newItems);
But the performance is really bad (since it checks if the item is in the dataprovider).
My current solution is:
dataProvider.getItems().clear();
dataProvider.getItems().addAll(subsidyRequests);
dataProvider.refreshAll();
But it requires a bit of knowledge (refreshAll, where to find the items) and the AbstractListDataView is hiding this complexity into convenient methods.
Additional context
Few other improvements: