It's not a secret anymore!*
The moose likes JSF and the fly likes Managing the width of the columns of datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Managing the width of the columns of datatable" Watch "Managing the width of the columns of datatable" New topic

Managing the width of the columns of datatable

Dwijen Bhattacharjee

Joined: Mar 31, 2008
Posts: 26
Hi all,
In my application I am showing a dataTable .The dataTable has 4 columns.
I want that all the columns will take same width(i.e. each column will 25% width of the dataTable) irrespective of the data length.
But I am not able to control that one beacuse <h:column> doesn't have width attribute.
What is happening in my application is that the columns size is diffrent depending upon the length of the example--

col1| col2 | col3 |col4
1 | jdjhsdhsdshj | 1 |2

as the length of the col2 data is bigger than others so it's taking the most of the width .
But I want that each column should have the same width.

How can i do that one.please help.
Zbyszko Palka

Joined: Nov 10, 2006
Posts: 13
you can use columnClasses attribute of dataTable tag to specify css classes for columns.
Please take a look at this page

[ May 19, 2008: Message edited by: Zbyszko Palka ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952

Almost anything visual for JSF is set by CSS.

Customer surveys are for companies who didn't pay proper attention to begin with.
Dwijen Bhattacharjee

Joined: Mar 31, 2008
Posts: 26
Thanks for yours reply .Actually I am already using ColumnClasses,StyleClass to display the table with some style..

In the columnClasses i used a css style to set the data alignment for diffrent if i add the width with that style all other pages where i am using the same style they also set to the same width. but that pages may have more or less number of columns so the alignment getting wrong.
for clarification i use the following css in columnClasses
text-align :"left";
text-align :"right";
now if i add width then all other pages are getting effected .
now one solution may be to use diffrent style sheet with diffrent width as appropate.but is it good practice? as there will be repetation of the alignment ;only the width is changing..please suggest.
It is sorta covered in the JavaRanch Style Guide.
subject: Managing the width of the columns of datatable
Similar Threads
Making a column invisible in a JTable
Help me to have a sortable table in my html profile!
how to set multpile style classes for headerClass attribute in datatable???
Screen resolution
JTable column width