I am trying to implement lazy loading with Grid in Vaadin 8. But it only shows an empty table. What do I do wrong? Also, how do I set the number of items to load (limit) to for example 20 items (the default is 40 items)?
private Grid<Image> makeLazyTable()
{
Grid<Image> grid = new Grid<Image>();
DataProvider<Image, Void> dataProvider = DataProvider.fromCallbacks(
query -> {
int offset = query.getOffset();
int limit = query.getLimit();
OffsetRequest request = new OffsetRequest();
request.setLimit(limit);
request.setOffset(offset);
List<QuerySortOrder> sort = query.getSortOrders();
return ImagesRepository.findAll(request, sort);
},
query -> ImagesRepository.getImageCount()
);
grid.setDataProvider(dataProvider);
return grid;
}
I did not add any columns. That was the reason why the table was empty. This way it works: