• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hiding / showing / resizing columns dynamically in a table

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic