What is the correct way to dynamically add and remove data to/from a Vaadin 8 Grid or ComboBox?
There seem to be no add or remove functions in Grid and ComboBox. This ist by design, I think.
But the DataProviders also do not offer such a functions.
If I use a ListDataProvider I have to create a new DataProvider every time I want to change the data list.
Event worse: I can not get the current list from the ListDataProvider so I have to store the list twice.
Edit: ListDataProvider.getItems().
Why does the ListDataProvider not support changing the data list?
What is the recommended way to display and change list data dynamically in an UI?
I didn’t test it but did you try to add/remove the item from the list ?
For example:
grid.setItems(yourList)
yourList.remove(item);
//refresh your grid
grid.getDataProvider().refreshAll();
// the item should be removed from the grid
That was too easy
I do have a special DataProvider to support filtering, but changing the ListDataProvider.backend list (getItems.add(…)) and calling refreshAll() did the trick.
Thanks.
I have the same issua right now and I’m trying to fix this but refreshAll() is not working, any advice please here: