0

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
vlcod
  • 229
  • 2
  • 3
  • 13

2 Answers2

3

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);
Víctor Gómez
  • 724
  • 6
  • 23
  • but no, it doesnt work) I mean user still can make it visible) And user shouldnt be able to make it visible – vlcod Dec 04 '15 at 14:02
1

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)

cfrick
  • 35,203
  • 6
  • 56
  • 68