I have a Vaadin 7 Grid and I would like to set a color to a specific column.
Grid grid = new Grid(container);
grid.setColumnOrder("column1","column 2","column 3");
I have a Vaadin 7 Grid and I would like to set a color to a specific column.
Grid grid = new Grid(container);
grid.setColumnOrder("column1","column 2","column 3");
Use one of the many column renderers. Easiest is probably the HTMLRenderer.
Example:
grid.addColumn("column1", String.class).setRenderer(new HtmlRenderer());
grid.addRow("data for column1", "data for column2", ...,
"<h1 style="background-color:Red;">data for column3</h1>");
See also: https://vaadin.com/docs/v7/framework/components/components-grid/#components.grid.generatedcolumns
This piece of code actually worked for me.I have been using Java 8 ,
Grid.setCellStyleGenerator((Grid.CellStyleGenerator) cellReference ->{
cellReference.getGrid().getHeaderRow(rowIndex: 0).getCell("column name").setStyleName("bg-blue");
}
Note :- bg-blue is the css rule mentioned in CSS file .