Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Center Grid Column Captions
I am not able to center the Grid column captions. I have the following CSS:
.text-align-center { text-align: center; }
I am setting the style like so:
HeaderRow headerRow = countSummaryGrid.getDefaultHeaderRow();
HeaderCell testCycleHeaderCell = headerRow.getCell("Test Cycle");
testCycleHeaderCell.setStyleName("text-align-center");
testCycleHeaderCell.setHtml("<strong>Test Cycle</strong>");
The caption is not centering. However, if I do the following in the footer, it does get centered:
FooterRow footerRow = countSummaryGrid.getFooterRow(0);
FooterCell totalsFooterCell = footerRow.getCell("Test Cycle");
totalsFooterCell.setStyleName("text-align-center");
totalsFooterCell.setHtml("<strong>Totals:</strong>");
Why would it work for the footer but not the header?
Thanks,
Steve
That should work. The best way to debug the problem is probably to use Chrome inspector (or equivalent) to see which CSS rules apply. It might be there is some more specific rule that overrides the centering.
-Pontus
Hi Pontus,
Thanks for the reply! I opened an issue on GitHub for this -> https://github.com/vaadin/framework/issues/9077
I don't see the style getting applied to the class when I inspect it in Chrome. It's either a bug or I am missing something really obscure. Either way, I would think the same technique should work on a HeaderCell that does on a FooterCell.
--Steve