Select first item in grid with lazy provider

Has anyone succeeded to implement first item in grid when populating data
with lazy data provider. Vaadin 23+

You can do that in the FetchCallback

Simply select the first item if there is no selection

Simon can you please explain it a bit more. I am using AbstractBackEndDataProvider

In the method you fetch the data call grid.select with the first item you get

You can use the dataview getItem(0) then select it. https://vaadin.com/api/platform/23.2.1/com/vaadin/flow/data/provider/DataView.html

Thank you. It was trivial with DataView.
dataProvider.addDataProviderListener((DataProviderListener) dataChangeEvent → {

        if (grid.getSelectedItems().isEmpty()) {

            gridDataView.getItems().findFirst().ifPresent(grid::select);

        }

    });