Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid + LazyLoad + Hibernate
Hi.
How can i do this?
tks
int limit = 100;
int page = 1;
int offset = (page - 1) * limit;
...
List<EntityUser> users = UserDatabaseAccess.getUsers(offset, limit);
Grid grid = new Grid();
grid.setContainerDataSource(new BeanItemContainer<EntityUser>(EntityUser.class, users));
grid.addScrollLoading(new LazyLoading()) {
onScroll() {
page++;
offset = (page - 1) * limit;
grid.appendData(UserDatabaseAccess.getUsers(offset, limit));
}
}
Have a look at https://vaadin.com/directory#!addon/viritin and https://vaadin.com/directory#!addon/lazy-query-container
Dave
The containers are interchangeable, so you should be able to use Lazy Query Container with either grid or table instead of beanitemcontainer in your snippet above.
I'm doing lazy loading with Grid, although I'm using my own lazy-loading container instead of the add-on conntainers I linked to.
Dave
Points to the own container.
Key methods what you need to implement are
size(), getIdByIndex(int) and getItemIds(int, int)
This way you get full control of item loading and can keep container very light weight.
Please, i want some examples.
1) how to set number of grid rows
2) how catch scroll event of grid
3) how apppend extra data to grid
thanks
Hi Jenk,
Number of visible rows is usually auto calculated when you use default height mode (https://vaadin.com/api/com/vaadin/shared/ui/grid/HeightMode.html#CSS).
Calculation magic only needs number of total rows thats why it is important implementa size method to the container.
Client side Grid does call to server RPC automaticly when user scroll grid in browser up or down and fetch objects that way for object feching only thing what you have to do is just implement container and in it fetch items lazy way.
This vaadin webinar does use Table but Container usage in Table and Grid is quite same(in server side) and there is coding examples how you can implement it by using lazy-containenr