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:

[code]
HeaderRow headerRow = countSummaryGrid.getDefaultHeaderRow();

HeaderCell testCycleHeaderCell = headerRow.getCell(“Test Cycle”);
testCycleHeaderCell.setStyleName(“text-align-center”);
testCycleHeaderCell.setHtml(“Test Cycle”);
[/code]The caption is not centering. However, if I do the following in the footer, it does get centered:

[code]
FooterRow footerRow = countSummaryGrid.getFooterRow(0);

FooterCell totalsFooterCell = footerRow.getCell(“Test Cycle”);
totalsFooterCell.setStyleName(“text-align-center”);
totalsFooterCell.setHtml(“Totals:”);
[/code]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