Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin 8 Grid how to remove item from grid?

Gökhan Öner
5 years ago Feb 15, 2017 12:45pm

I want to remove an item from Vaadin 8 grid, but as far as I see, it's not possible, or is it ?

Jean-Christophe Gueriaud
5 years ago Feb 16, 2017 12:41pm
Gökhan Öner
5 years ago Feb 16, 2017 12:52pm
Jean-Christophe Gueriaud
5 years ago Feb 16, 2017 2:26pm
Gökhan Öner
5 years ago Feb 16, 2017 2:46pm
Pekka Hyvönen
5 years ago Feb 16, 2017 3:17pm
Gökhan Öner
5 years ago Feb 17, 2017 12:33am
Pekka Hyvönen
5 years ago Mar 22, 2017 9:36am
Johannes Laidler
4 years ago Jul 27, 2017 8:27am
Pekka Hyvönen
4 years ago Jul 31, 2017 10:29am

We don't currently have that ticket in scope, since it is considered as an improvement that is not a must have and we have other things that have higher priority for now.

I recommend doing a +1 on the ticket, it doesn't quarantee we'll do it immediately, but at least we can see that it is a requested feature.

Luca Pertile
4 years ago Aug 07, 2017 10:44am

If your dataprovider source is a java.util.List you can simply remove item from there, then do a Grid.getDataProvider().refreshAll().

Joachim Dietl
4 years ago Aug 22, 2017 6:41am

How to remove items from a grid?

This does not work:
grid.getDataProvider().getItems().remove(app);
grid.getDataProvider().refreshAll();

I have to switch views to see the effect of the removal operation.
 

Luca Pertile
4 years ago Aug 22, 2017 6:48am

Joachim Dietl: How to remove items from a grid?

This does not work:
grid.getDataProvider().getItems().remove(app);
grid.getDataProvider().refreshAll();

I have to switch views to see the effect of the removal operation.

 

You have to keep a reference in your code to the list:

List<MyEntity> entities = service.getMyEntities();
grid.setItems(entities);
...
entities.remove(anEntity);
grid.getDataProvider().refreshAll();

I use this template in my project and it works perfectly.
 

Joachim Dietl
4 years ago Aug 22, 2017 7:00am
Luca Pertile
4 years ago Aug 22, 2017 7:06am

Somewhere in documentation I read that, by default, Vaadin create a ListDataProvider when we use grid.setItems().

Jet Beray
4 years ago Oct 12, 2017 3:19am
Alexander Cherepanov
4 years ago Feb 12, 2018 9:53am
Luca Pertile
4 years ago Mar 22, 2018 8:12am
Alexander Cherepanov
4 years ago Mar 22, 2018 8:26am