Locking colums in HTML table (IE only) html

Locking colums in HTML table (IE only)

In a project I’m working on we have a HTML table with many columns for editing certain records. The users requested the possibility to lock the first column so that when scrolling they could see the context, like they can in for example Excel. In HTML this is not a trivial task.
I found Brett Merkey’s excellent website showing a very simple way to achieving this feature with Cascading Stylesheets. There is one caveat though, it only works for Internet Explorer 5+. In our case that is not an issue luckily.

To speed up the performance considerably with tables with many rows, I made a simple function caching the DIV container . It also encapsulates the div container name on the page instead of the stylesheet.

var container;
function find() {
  return (container != null?container:document.getElementById('tbl-container'));
}

In the stylesheet I then use the following expression

     left: expression(find().scrollLeft);)

One Response

  1. Bala April 13, 2005