Hengrui Jiang
Hengrui Jiang

Reputation: 881

Dynamic page length for Vaadin Table with big tables

My goal: the Vaadin Table should take 100% height of the parent element (HorizontalLayout).

I do know that I could set the page length to 0, but as my table is really long, I would like to keep the lazy loading behavior. Is there a way to make Vaadin determin the page length dynamically?

Update: I found a hack with

.v-table-body {
    height: calc(100% - #{($v-table-row-height + 3 * $v-table-border-width)}) !important;
  }

in SCSS, which sets the height correctly. However, besides the fact that using !important is kind of disturbing here, the lazy also still shows line numbers in 15 rows step, i.e. 1-15....

Upvotes: 2

Views: 772

Answers (1)

Axel Meier
Axel Meier

Reputation: 1127

What I found out is: you can just write

table.setSizeFull();
horizontalLayout.addComponent(table);

The table is larger now and shows more Objects depending on your screen size. But still the table works with a cache. You can see also in the network tab in Chrome's developer tools that not all elements are send but only a fraction of it (visible rows + cached ones). By debugging I found out that the pageLength member of the table changed according to the number of visible elements.

You don't need to set the page length and you don't need your CSS hack.

Upvotes: 0

Related Questions