Get List<items> from Vaadin Grid

Leviand :

Problem: I have a Vaadin 8 Grid , and I can't find a way to extract the items inside of it.

Description: Starting from a grid

Grid<Pojo> myGrid = new Grid<>();

I've configured it so it can take data with lazy loading.

    myGrid.setDataProvider(
            (sortOrd, offset, limit) -> dao.getAllFiltered(offset, limit, filter),
            () -> dao.getCountAllFiltered(filter)
    );

At this point, I want to extraxt all the items from the grid (for putting that into an excel), something like List<Pojo> list = myGrid.getItems();. I've also tried passing through myGrid.getDataProvider() , but there are no useful getter into it.

I can't find any getter, how can I achieve this? Thanks

O. Ozturk :

Have you tried this basically?

List<Pojo> list = grid.getDataProvider()
                      .fetch(new Query<>())
                      .collect(Collectors.toList());

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=84945&siteId=1