HighDots Forums  

fixing column width in a dynamic table

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss fixing column width in a dynamic table in the HTML forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
jd
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 12:31 PM






rocketmonkeys (AT) gmail (DOT) com wrote:
Quote:
The contents will just wrap onto more rows without changing the column
size, assuming they can be wrapped (not like a big image that will
force the width).

What you could do in javascript, as someone mentioned, is to first load
the table with the default contents and record the widths, then set
them explicitly and they'll stay constant:
I tried this and it doesn't work for me, not sure why.
I tested in both Firefox and in IE and both still change the column
widths even after I have explicitly set them to specific values (in
pixels).

-- jeff



Reply With Quote
  #12  
Old   
jd
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 12:33 PM







Jim Moe wrote:
Quote:
chimalus (AT) gmail (DOT) com wrote:
I don't want to specify column widths in the stylesheet since they're
not known at design time.
The "overflow:hidden" shouldn't be necessary
because the table columns are already wide enough to
accomodate all the text.

- The widest width is not known.
- The widest width is known since the text fits in it.
Which is it?
At design time, the widest width is not known.
When the page is displayed, the widest width is known since the text
fits in it.

(have I answered the question?)

-- jeff



Reply With Quote
  #13  
Old   
rocketmonkeys@gmail.com
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 03:24 PM



You tried my code? We're going to have to see your page in its
entirety. Probably best to send it via email, rocketmonkeys (AT) gmail (DOT) com,
post here when you've sent it. The code I posted works for me in IE 6
XP SP2, and Firefox 1.5. It could be something else on the page is
interfering.

-james


Reply With Quote
  #14  
Old   
rocketmonkeys@gmail.com
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 03:27 PM



I think it's like this:
-Display the table with no widths specified at all (let the layout
engine decide cell widths/heights.
-Now keep those columns the same width even after dynamically modifying
content.

For this scheme, no HTML or CSS will work. There are hacks, like
specifying all the same width, or specifying overflow:hidden (which I
think would cause unwanted side effects). But I think javascript is
the only way to do exactly what Jeff wants.

Jeff, accurate?


Reply With Quote
  #15  
Old   
jd
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 06:34 PM




rocketmonkeys (AT) gmail (DOT) com wrote:
Quote:
I think it's like this:
-Display the table with no widths specified at all (let the layout
engine decide cell widths/heights.
-Now keep those columns the same width even after dynamically modifying
content.

For this scheme, no HTML or CSS will work. There are hacks, like
specifying all the same width, or specifying overflow:hidden (which I
think would cause unwanted side effects). But I think javascript is
the only way to do exactly what Jeff wants.

Jeff, accurate?
Yes, that's accurate.



Reply With Quote
  #16  
Old   
jd
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-16-2005 , 07:33 PM




rocketmonkeys (AT) gmail (DOT) com wrote:
Quote:
You tried my code? We're going to have to see your page in its
entirety. Probably best to send it via email, rocketmonkeys (AT) gmail (DOT) com,
post here when you've sent it. The code I posted works for me in IE 6
XP SP2, and Firefox 1.5. It could be something else on the page is
interfering.
Well, I didn't actually try your code, but I tried your technique.
As you've requested, I've emailed you a page. Thanks for taking the
time
to look at this.

-- jeff



Reply With Quote
  #17  
Old   
jd
 
Posts: n/a

Default Re: fixing column width in a dynamic table - 12-20-2005 , 04:37 PM



Here's the solution I came up with:

Add an extra row to the table with the same number of
columns (cells) as the rest of the table. For each cell
in the row, set its style.paddingLeft to the style.offsetWidth
of an an existing cell in the same column. Set the
style.visibility of the new row to "hidden".

There are one or two tricks here (depending on how
you count ;-)

- After the table is rendered for the first time, use the
width of each column as it was rendered to determine
the desired size of that column.

- To fix the size of a cell, set its padding, not its
width. The table layout manager is apparently allowed
to play around with widths (treat them as a hint rather
than a requirement), but setting the padding creates a
minimum size that it can't mess with. I tried many
variations on setting cell/column width only to find that
none of them seemed to work. Using padding is similar
to the common suggestion of using an invisible image,
but it allows the width to be determined dynamically and
also eliminates the overhead of those extra images.

-- jeff


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.