wood burning stoves 2.0*
The moose likes JSF and the fly likes Centering a column heading in a datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Centering a column heading in a datatable" Watch "Centering a column heading in a datatable" New topic
Author

Centering a column heading in a datatable

E Paisley
Greenhorn

Joined: Sep 22, 2008
Posts: 14
This is going to sound like a real newbie type question...

How do you center a column heading in a datatable. What I need to do is center the column heading but have the data be right aligned. I can't get the heading to act one way (center) and the column to act another (right aligned).

Any suggestions?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

CSS


Customer surveys are for companies who didn't pay proper attention to begin with.
E Paisley
Greenhorn

Joined: Sep 22, 2008
Posts: 14
Thanks for the suggestion, although I am already doing that... The entire column only responds to the style in the header and not in the data values

[ October 01, 2008: Message edited by: Eric Paisley ]
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Try this if using verbatim is OK for you.



If it does not works out in this way try putting the whole column in div.
Hope this works.
[ October 01, 2008: Message edited by: Himanshu Gupta ]

My Blog SCJP 5 SCWCD 5
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Actually, it's usually enough to define a table headerClass attribute with centering, then define the columnClass for that column with right, left, or center alignment depending on what looks best for that column.

I do that all the time, such as when displaying columns with currency values (right-aligned) and text values (left-aligned), often centering items like dates and Y/N value columns.
 
Consider Paul's rocket mass heater.
 
subject: Centering a column heading in a datatable
 
Similar Threads
Problem with spacing
text-align in h:dataTable
How to remove the record number from GUI
column HEADER problem
To display webpage in JEditorpane