Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hiding / showing / resizing columns dynamically in a table

Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • 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>
<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.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic