Select row in grid with lazy load

I want to select (grid.select(item)) row in grid after edit or new item. Grid has DataProvider which lazy load data from service.
Which event user or other way to recognize when items is displayed in grid?

Not sure what you mean; I assume that you call DataProvider.refreshAll() after an item has been edited, or a new item has been added to the collection. There you can update the selection by grid.select(item); you can also use DataProvider.addDataProviderListener() to hook into the refreshAll() call. You can also call grid.select(item) even when the item is not yet fetched into the Grid itself - the Grid should select the row properly after the data is fetched.

Thank you, but not working:


grid.getDataProvider().refreshAll();
grid.select(employee);


https://github.com/zesetup/vaadin-spring-billet/blob/ace50080adec1ca2399069a2686eeacbf4076d3e/src/main/java/com/github/zesetup/vaadinspringbillet/ui/vaadinUI.java#L92

With “DataProviderListener” not working too:

DataProviderListener<Employee> dataProviderListener = new DataProviderListener<Employee>() {
      @Override
      public void onDataChange(DataChangeEvent<Employee> event) {
        grid.select(employee);
      }};
    grid.getDataProvider().addDataProviderListener(dataProviderListener);


https://github.com/zesetup/vaadin-spring-billet/blob/1a0f90149dba7128bdee396580f3a263eeb266f9/src/main/java/com/github/zesetup/vaadinspringbillet/ui/vaadinUI.java#L97

If there is real framework issue, it sounds a bit similar to discussion here

https://github.com/vaadin/framework/issues/10152

If you overwrite equals in your Employee data class then it will work.
This function is not working:

public Boolean equals(Employee e) { return e.getId().equals(id); }

It should be something like that:

@Override
public boolean equals(Object other) {
if (id == null) {
return super.equals(other);
}

return this == other || other instanceof Employee && id.equals(((Employee) other).id);
}

Thanks, solved!

Other problem, after grid.select(item) this row not de-selected after clicking on other rows. Grid in Single select mode.

Problem with grid.getDataProvider().refreshAll(); after this row selected and no way to deselect.

Sorry, was fixed in newest Vaadin framework.