Coloring column in Gridlayout


I would like to color one column from the gridlayout. How could this be done?

Thanks in advance.

If I remember correctly, there is no support for setting individual style names for GridLayout cells.

You can of course put components/layouts in the cells that have the style set (maybe overriding GridLayout.addComponent(Component, int, int, int, int) to set it automatically for some column), but that is not quite the same thing.

If I remember correctly, FastGrid from the
FastLayouts add-on
should copy also component styles to the cells containing them; standard GridLayout doesn’t. This way, components that do not fill the cell could be handled better, but the general approach is still almost the same.

It might also be possible to do this somehow directly in CSS, I’m not sure.

And I already have components in some cells that are in this column that I would like to color. So I think it’s not possible to add layout on that column anymore?

You could wrap the components e.g. in a CssLayout if necessary.

In practice, you would probably need to set the background color both for the component and for the layout. Ideally, you would set it for the grid cell that contains the component and for the component itself, which you might be able to do with FastGrid.

Note that I don’t think anybody has tested the compatibility of FastGrid with the latest Vaadin versions - it might work our of the box or there might be problems. FastGrid does not support column expand ratios.