Loading...
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
TUTORIAL

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

How to hide one column in vaadin table

Arun R T
10 years ago Oct 18, 2012 12:30pm
Johannes Dahlström
10 years ago Oct 18, 2012 1:08pm

If you use the addItem(Object[] cells, Object itemId) overload, note that the cells array must match exactly those columns that are actually visible, not the properties in the underlying Container. Yes, this is a bit weird. You can still add whole Items to the Table using addItem(Object).

setVisibleColumns() is not really designed to be called more than once - for instance, it removes header, alignment and icon from the non-visible columns and has no way of restoring them if a non-visible column becomes visible again.

As an alternative, you might set the columns collapsible and collapse the unwanted columns. The drawback is that the table will then contain a small button that allows the user to collapse and uncollapse the columns as well.

table.setColumnCollapsingAllowed(true);
table.setColumnCollapsed(columnId, true);
// you can set individual columns non-collapsible
table.setColumnCollapsible(otherColumnId, false);
Arun R T
10 years ago Oct 18, 2012 4:43pm
Charles Anthony
10 years ago Oct 19, 2012 9:05am
Arun R T
10 years ago Oct 19, 2012 11:44am
Johannes Dahlström
10 years ago Oct 19, 2012 2:27pm
Do note

that hiding the column selector on client side is purely cosmetical and can easily be circumvented by the user, so this is not at all a secure way to do it if the columns contain sensitive information that the user is not supposed to see.

Charles Anthony
10 years ago Oct 22, 2012 8:18am
Martin Wildam
6 years ago May 13, 2016 9:49pm
Ankita Bhalerao
3 years ago Apr 22, 2019 5:59am