Tuesday, March 08, 2005
by Nik Kalyani
Tuesday, March 08, 2005 10:36:49 PM (Pacific Standard Time, UTC-08:00)

I am working on a web app that consists of a treeview on the left and content on the right. The basic layout is a table with the height of the content determining the overall height of the table.

This basically means the treeview has to be scrollable, since it's possible that the table height is less than the tree height. Simple enough...put the treeview inside a DIV and change its "height" style attribute to 100%.

Works in IE6 but does not in FireFox. After Googling for hours and not finding a good solution, I devised a function to make this work. In my function, the params are the ID's of the main table and the DIV containing the treeview. The code first sets the height of the scrollable DIV to 0. This allows the main table to adjust to its normal height. Then the DIV's height is set to the same as the table height.

Works in IE6 and FireFox.

function setScrollerHeight(mainTableId, explorerScrollerId)

         var mainTable = document.getElementById(mainTableId); 
         var scroller = document.getElementById(explorerScrollerId); 
         if (!scroller) return; 
         if (mainTable.clientHeight > 0) 
         { 
                  scroller.style.height = "0px"; 
                  scroller.style.height = mainTable.clientHeight; 
         }
         else 
                  scroller.style.height = "500px"; }

Saturday, August 18, 2007 2:21:37 PM (Pacific Standard Time, UTC-08:00)
I've got (had) a similar problem while moving my site to HTML 4.01 and trying to get rid of tables in the process (as I write I'm still working on it so the new version is not visible).

I've spent a few days researching ways to render this kind of requirement (with a few more...) with only div's to realize it didn't make sense: when tables are more appropriate or make things simpler I now use tables. As simple as that.
Saturday, August 18, 2007 2:24:00 PM (Pacific Standard Time, UTC-08:00)
I think I have completely misunderstood the point you were making, so please delete my previous comment and this one.

Sorry for the noise.

Ilan
Ilan
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, i, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

Contact me: nik*kalyani.com (replace "*")

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 213
This Year: 31
This Month: 8
This Week: 0
Comments: 235
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani