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.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin Table height is changed Automatically?

Saravana Kumaran
1 decade ago Apr 22, 2010 5:28am
Dmitri Livotov
1 decade ago Apr 22, 2010 5:36am
Jouni Koivuviita
1 decade ago Apr 22, 2010 7:39am

Dmitri Livotov: table's page length is not a height for a table, this is an amount of rows that will be pre-fetched from the server-side to display in a table.

Almost correct. One small correction:

When the Table's height is left undefined (null or -1), the height is determined by the pageLength. So if the pageLength is 10, ten rows should be visible in the table, and the table's height is exactly ten times one row's height plus the header. And as Dmitri said, if the pageLength is zero, all rows will be visible, without a scrollbar.

But I'm a bit baffled by the relation of this to the screen resolution? Only if you use relative sizes for the table should screen size have any difference in the layout.

Can you post a code snippet that exhibits this behavior?

Saravana Kumaran
1 decade ago Apr 24, 2010 6:21am
Artur Signell
1 decade ago May 04, 2010 5:32am
Kimball Robinson
9 years ago Dec 04, 2012 9:10pm

I was working a similar problem. I wasn't worried as much with the exact table's height as with how many rows were being displayed.

In my case, I want the table to expand as rows are added, so that the table is always just a little bit bigger than it needs to be.

Here's some example code. I've only included the most relevant bits, so you can't just run it on its own.

public class MyClass extends Table {

	public MyClass(...)
		this.setWidth("100%"); // fill parent <td>'s width, allows draggable sizing.
		// note: do NOT setHeight().



	// I also have a function (not shown) to add rows to the table when 
		// a button is clicked.  That function calls adjustHeight() (shown below).

	public void adjustHeight()
		this.setPageLength(this.getItemIds().size() + 1);
Last updated on Dec, 4th 2012