Vaadin 8.5.1- Refresh grid after row update

前端 未结 2 1569
青春惊慌失措
青春惊慌失措 2020-12-22 01:26

I am using Vaadin 8.5.1 Grid to display 1000\'s of rows. Once a row is updated with change in it property, I use grid.getDataProvider().refreshItem(selectedRow)

2条回答
  •  [愿得一人]
    2020-12-22 02:09

    For a item to be seen as the same item, (and the refresh working) you need a corretly implemented equals() and hashCode() methods on the object.

    From the documentation

    public void refreshItem(T​ item)

    Description copied from interface: DataProvider

    Refreshes the given item. This method should be used to inform all DataProviderListeners that an item has been updated or replaced with a new instance.

    For this to work properly, the item must either implement

    equals(​Object) and #hashCode() to consider both the old and the new item instances to be equal, or alternatively

    DataProvider.​getId(​Object) should be implemented to return an appropriate identifier.

    In addition to this, it's you should create a ListDataProvider, assign it to the grid and then do the updated via the same instance of the previously assigned ListDataProvider

提交回复
热议问题