I would like to create a table with scrollable data. I have to freeze the first row and first column of the table. The first row and first column of the table must automatically resize in width and height to the variable cell dimensions in the content area of the table (because the user will be adding new table cells with variable amount of content).
Someone asked a related question: How can I lock the first row and first column of a table when scrolling, possibly using JavaScript and CSS?
But the link to online demo and source code is dead, so I am unable to confirm the solution.
Use the excellent jQuery Datables with the FixedHeader extension.
Scroll down past the header row, and you'll see it glue itself neatly to the top of your screen.
For header, footer, left and right excitement:
http://datatables.net/release-datatables/extras/FixedHeader/top_bottom_left_right.html
Ok, I read a lot of answers on the web and finally assembled a demo that worked. I'm using PHP to create 50 rows in the table, but you can just as easily hard code the data. I essentially created four quadrants (div.q1, div.q2, div.q3 and div.q4), where the fourth quadrant contains the actual data table. I used jquery to copy the table in the fourth quadrant into the second and third quadrant before synchronizing their scroll bars. I used a combination of CSS overflow, width, height and display properties to hide unnecessary TD elements in each of the quadrants. Here's a full working example:
You render the table twice: