Hide columns in a Grid Component.

Hi everybody.

Somebody know how to hide columns in Grid component?

It’s a good component for to freeze columns but the develop team didn’t count with the idea of hide columns, very helpful to developers who saves the complete object in a hidden column.

Any idea?

Thanks so much.

Hi,

you have to remove the “column” from the container.

Example:

// Hide not internal columns
            final GeneratedPropertyContainer wrapperContainer = new GeneratedPropertyContainer(container);
            wrapperContainer.removeContainerProperty("internalId");

But this form does not let me know wich is the internalId when I do double click in the row,

I need the container has the column but not visible.

Thanks a lot by de aswers.

In that case remove column from the Grid.
Example:

myGrid.removeColumn("columnName");

Now I can do like I wanted.

Thanks a lot!

internalId is only the property name of the column in my container.
it`s clear that you have other “property” column names.

I found very usefull setColumns method (7.5.0+). You can select very easy what propertyIds you want to see in the table and also the order in the table.

Object[] VISIBLE_COLUMN_IDS = new String[]
{"propId1", "propId2"...};
grid.setColumns(VISIBLE_COLUMN_IDS);

this exemple how to hide column “id”

grid = new Grid();

grid.addColumn(“id”, String.class);
grid.addColumn(“nom”, String.class);
grid.addColumn(“prenom”, String.class);

Grid.Column column = grid.getColumn(“id”);
column.setHidden(true);