atmd
atmd

Reputation: 7490

Vaadin new Table creates 2 separate tables

I am working on a legacy application which uses Vaadin, which is uses Google web tools internally)

I found that the tables in the mark up where created using multiple tables where one table would do. I set up a blank Vaadin project and found the same thing:

using this code:

//import com.vaadin.ui.Table;
final VerticalLayout layout = new VerticalLayout();

layout.setMargin(true);
setContent(layout);

Table table = new Table("The Brightest Stars");

table.addContainerProperty("Name", String.class, null);
table.addContainerProperty("Mag", Float.class, null);

table.addItem(new Object[] { "Canopus", -0.72f }, 2);
table.addItem(new Object[] { "Arcturus", -0.04f }, 3);
table.addItem(new Object[] { "Alpha Centauri", -0.01f }, 4);

table.setPageLength(table.size());

layout.addComponent(table);

a table is rendered on the front end:

enter image description here

However when you look at the mark up, vaadin has created a separate table just for the headings (rather then use a 'th' element in the table.)

enter image description here

This seems a crazy thing to do. I'd say this was a bug, but from the vaadin doc's etc, this is correct behavior. Is there any way to disable this??

Upvotes: 0

Views: 119

Answers (1)

André
André

Reputation: 2204

It's not a bug, it's a feature.

Scroll Table

If you look at this table, you can see there is a scroll within the table, not the whole grid, making the headers fixed. This way, the cell header stay on top the whole time.

This is a common use case, I remember implementing to a custom widget and reached a similiar solution to achieve this feature.

I never tried to use Vaadin, but looking up the source of vaadin.ui.Table there is some render modes to the column. Sorry for not being that helpful.

setColumnHeaders(String[] columnHeaders) Javadoc

Upvotes: 3

Related Questions