Headers

What if we want to change the header of a column at runtime? This couldn't be more easier:

table.setColumnHeader("Column 1", "There you have, a new header");

In the preceding line of code, the first parameter is the property ID for the column, and guess what! The second parameter is the new header text. You can change all headers with a single call:

table.setColumnHeaders(new String[] {"Header 1", "Header 2"});

Are you interested in getting an array with the current column headers? There you go:

String[] columnHeaders = table.getColumnHeaders();

Maybe just the header for one particular column:

String columnHeader = table.getColumnHeader("Column 1");

You must provide the property ID of the desired column in the previous call.

Would you like to build ...

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.