wood burning stoves 2.0*
The moose likes Struts and the fly likes Hiding / showing / resizing columns dynamically in a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Hiding / showing / resizing columns dynamically in a table" Watch "Hiding / showing / resizing columns dynamically in a table" New topic
Author

Hiding / showing / resizing columns dynamically in a table

Rick Nendza
Greenhorn

Joined: May 16, 2004
Posts: 5
Sorry if this one doesn't below in the struts forum but i am using struts tag libs for display

basically.. how to i dynamic change colspan attibutes and the width of certain columns based on the amount of columns that will display in a row passed on a sql select from the table.. ie.. if 2 columns are displayed i might want the width of column 1 to be 120 and column 2 to be 480.. but if 5 columns are to display i might want width of column1 to be 100 and col2 to be 120 col 3 to be 130..etc.etc..
also i need to changed the colspan on the table header appropriately to span the correct number of columns.. how can i keep my presentation layer clean to avoid a bunch of if then else scriptlets?

Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I would imagine you mean the width attribute. colspan refers to the number of tds it takes up going across.

If you wanted them all equal:

<% int myMaxTableWidth = 670; //or whatever %>
<% int numCols = myList.size() %>

<td width='<%= myMaxTableWidth / numCols %>'>...</td>

If you didn't want them equal, play around with:
<td nowrap>
and
<td width="100%">
- possibly putting them together <td nowrap width="100%">
it might just give you what you're looking for without the dynamic stuff.


A good workman is known by his tools.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hiding / showing / resizing columns dynamically in a table