How to set background color in vaadin grid header cells

2.4k views Asked by At

How can I set the background color of the header of a grid(table) in Vaadin. I tried to use:

grid.setCellStyleGenerator(cellRef -> (REFERENCES_INCLUDED_COLUMN + levelList.get(0).getName()).equals(cellRef.getProperty()) ? "rightalign" : null);

where the REFERENCES_INCLUDED_COLUMN has the header information and right align is the CSS styling. But I didn't work.

IS there any css styling which I can do?

1

There are 1 answers

0
user1631306 On BEST ANSWER

I found the answer some where on Vaadin forum. Instead of using

grid.setCellStyleGenerator(cellRef -> (REFERENCES_INCLUDED_COLUMN + levelList.get(0).getName()).equals(cellRef.getProperty()) ? "rightalign" : null);

which I feel can be useful if we want to do styling for specific cells, I ended up using proper CSS styling

.v-grid .v-grid-header th.v-grid-cell {
    background:#5A9CC5;
    color: white;
}