vlcod
vlcod

Reputation: 229

How to hide column in filteringtable vaadin 7?

I have 5 columns in my table, and how is it possible to make one of the columns invisible? is it any standard approach for that, or maybe, can I use css for that?

Upvotes: 0

Views: 2068

Answers (2)

cfrick
cfrick

Reputation: 37033

In case you just don't want to show them at all, use setVisibleColumns on the Table:

public void setVisibleColumns(java.lang.Object... visibleColumns)

Sets the array of visible column property id:s.

The columns are show in the order of their appearance in this array.

Parameters:

visibleColumns - the Array of shown property id:s.

(also setContainerDataSource) allows passing the visisible columns)

Upvotes: 1

Víctor Gómez
Víctor Gómez

Reputation: 722

You need to allow column collapsing in your table

table.setColumnCollapsingAllowed(true);

After that, you can collapse or hide any column

table.setColumnCollapsed("columnId", true);

An example:

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

// Define two columns for the built-in container
table.addContainerProperty("Name", String.class, null);
table.addContainerProperty("Mag",  Float.class, null);

// Allow column collapsing
table.setColumnCollapsingAllowed(true);

// Hide column "Name"
table.setColumnCollapsed("Name", true);

Upvotes: 3

Related Questions