PDA

View Full Version : Howto align text within grid cells?



andreiastra
17 Aug 2010, 7:58 AM
Is there a simple way to specify the vertical alignment of text in grid cells?

Or, should I write a custom GridCellRenderer for that?

sven
17 Aug 2010, 7:59 AM
You can specifiy an alignment on the ColumnConfig. It is demonstrated here: http://www.sencha.com/examples-dev/explorer.html#basicgrid

andreiastra
17 Aug 2010, 8:06 AM
Thanks, Sven for your prompt reply.

I can see that I can set the horizontal alignment:

grid.getColumnModel().getColumn(i).setAlignment(horizontalAlignment);

I couldn not see how I can specify the vertical alignment in ColumnConfig.

I need to have the text in the grid cell to be vertically centered within the cell.

sven
17 Aug 2010, 8:10 AM
Ok, sorry. I overread that. You can either use a custom GridCellRenderer, or define some style on the columnconfig.

andreiastra
17 Aug 2010, 8:11 AM
Great! Thanks a lot!