I want to set the background color of a gridlayout cell. The cell will contain a simple string. To do this, I created a horizontal layout and set its size to full. I placed a label within the layout and added a style to the layout. I then added the layout to the gridlayout. Unfortunately, the horizontal layout does not fill the entire cell. The background color only fills the part of the cell containing the text.
Here is the code:
HorizontalLayout labelLayout = new HorizontalLayout();
labelLayout.setSizeFull();
labelLayout.addStyleName("form-summary-label");
Label label = new Label("foo");
label.setWidth(null);
labelLayout.addComponent(label);
gridLayout.addComponent(labelLayout, 2, 3);
From the documentation, I thought I only needed to set the labelLayout’s size to full and that would do it. I also tried setting the label’s size to full and that did not work either.
The FastGrid class in the
FastLayouts add-on would also copy the style from the contents to the cell, allowing such things. It has not been updated in a long time, though, so I’m not sure if the add-on works with the latest Vaadin versions without modifications.
I think there is no way how to set a background color for one row in GridLayout. :mad:
Maybe those FastLayouts. But FastGrid lacks lot of GridLayout functionality.