Hey, I have a question regarding tables

I have tried to make a table for practice

Window mainWindow = new Window(“Table Application”);

final Table table = new Table(“This is a table”);
table.addContainerProperty(“First name”, String.class, null);
table.addContainerProperty(“Last name”, String.class, null);
table.addContainerProperty(“Year”, Integer.class, null);

	table.addItem(new Object[] {"abe","lincoln", new Integer(1473)}, new Integer(1));
	table.addItem(new Object[] {"Tom","Hardy", new Integer(1973)}, new Integer(2));
	table.addItem(new Object[] {"Harry","Hari", new Integer(1689)}, new Integer(3));
	table.addItem(new Object[] {"Ritvik","Salim", new Integer(1242)}, new Integer(4));

I do end up generating the table, when I run it on the server (J2EE), However, I also get a large blank space immediately below the table. Does anyone know why this is happening?

Thanks in advance.



If you’re referring to the empty space inside the Table itself, then that is the reserved space for additional Table rows.

By default, Table has a so-called page-length of 10, if I’m not mistaken, which refers to the amount of rows visible (if no explicit height is set with setHeight() methods) and the amount of rows the table usually caches beyond the visible area (to make scrolling seem more instantaneous).

You can modify this behavior by setting a new page-length with setPageLength(int) method. I believe the value ‘-1’ should make the table adjust to the height of all rows in the table.

And remember to not set an explicit height then, otherwise the table will respect that height setting.

Did these help?

Actually I figured that part out.

I realize i just have to include.

However, is there anyway by which I could only see two rows at a time and will have to scroll down to see the nest two rows and so on?


Okay, so it was 0, not -1. My bad. But hey, quite close, you must admit :wink:

Just set the page-length to 2, and that should do it.