How to style a Grid's column header

Hi,

in Vaadin8 I would do the following to style a column header in a Grid:

if (null != styleGenerator) { // styleGenerator is a String
	column.setStyleGenerator(c -> styleGenerator);
	this.getDefaultHeaderRow().getCell(id).setStyleName(styleGenerator); // id is a String
}

In Vaadin14 I was able to reproduce the first part, i.e.: styling the data cells in a column, but not the header cell:

this.getDefaultHeaderRow().getCell(column)... // now what?

Anything I missed? I can’t find help on the official docs (which, by the way, seems not to load for 14.0.1).

Thanks a lot,
MZ

To merely align the content, one could use the Grid.Column.setTextAlign() method, which also works on the column header.

Still, it would be useful if a generic CSS class could be easily added to the column header too; or must we use Components and style them?

Thanks,
MZ

Marco Zanon:
To merely align the content, one could use the Grid.Column.setTextAlign() method, which also works on the column header.

Still, it would be useful if a generic CSS class could be easily added to the column header too; or must we use Components and style them?

Thanks,
MZ

This is working only for single header. For multiple header it makes alignment only to last header.

Hi,

This is working only for single header. For multiple header it makes alignment only to last header.

actually I’m getting it to work with multiple columns too: could you please elaborate a little your problem?

Thanks,
MZ

Marco Zanon:
Hi,

This is working only for single header. For multiple header it makes alignment only to last header.

actually I’m getting it to work with multiple columns too: could you please elaborate a little your problem?

Thanks,
MZ

It works for multiple column but you need to create multiple header and it will apply for only last header.

Hi Imran,

sorry I misunderstood Your first request.

Actually I only use single-header columns, so I have no experience in styling - or merely aligning - multiple-header columns.
Maybe anyone in the forum has better ideas?

Thanks,
MZ