Problem with visualization new items of a Grid

Hi everyone!

I’m having a problem with the update of the item of a component Grid. I’m using grid.setValues(values). For the element that i set from database no problem the grid visualize all. For element that i temporaly save in a ArrayList the grid don’t want show it, i have to switch tabs for do it visible.

I think so was for the setVisible(), i try but nothing.

What could be?
ty
image.png
image.png

From your explanation it’s hard to understand what you have done in your application. Keep in mind that just adding the items to the list doesn’t not refresh the grid, you have to refresh the data provider or set the items again.

So i have to use DataProvider instead ArrayList? I define the list like that:

private final List data= new ArrayList<>();

Also i create method for update the items:

    private void updateGridRitiro() {
    grid.setItems(db_service.findAll());
    grid.recalculateColumnWidths();
}

private void updateGridDisponibilita() {
    grid.setItems(data);
    grid.recalculateColumnWidths();
}

The second method works, but you have to call it again if the items in the list changes - there is no way for Vaadin to know that your list has changed

I call it when i create the grid and after i add object in the List data, but i must click on other tabs and come back for see any change

Then there must be a bug in your code somewhere, this essential function works :grimacing:

You can also check if the refresh of the Dataprovider helps, there could be an optimization that setting the same data again, does not refresh the grid, but that relies on e.g. the list returning the same hash code which should normally not be the case if you haven’t customized a lot of things

Ok i will try

U will hate me…i use all time another method update of another grid in the interface. And i check it 2-3 times :man_facepalming:
Obv now work all how will do <:troll:805128363676270642>

Ty for carry :kissing_heart:

Hehe, good to hear it works :see_no_evil: