Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollable HTML table with top row and left column frozen

Has anyone been able to implement a scrollable table in HTML where the TOP row and LEFT columns are frozen, but the rest of the table is scrollable? A perfect example of this is: Google Squared

I tried to reverse engineer the code for the google squared table, but I have been unsuccessful so far.

Note: I need the ability to FREEZE the TOP ROW and the LEFT COLUMN at the same time.

like image 544
Jon Avatar asked Jul 08 '09 22:07

Jon


People also ask

How do you freeze a column and row in an HTML table?

To freeze the row/column we can use a simple HTML table and CSS. HTML: In HTML we can define the header row by <th> tag or we can use <td> tag also. Below example is using the <th> tag. We also put the table in DIV element to see the horizontal and vertical scrollbar by setting the overflow property of the DIV element.

How do I create an HTML table with a fixed frozen left column?

It is possible to create a table, which has a fixed left column and a scrollable body. For that, you'll need to use some CSS. You can use the position property set to “absolute” for the first column and specify its width. Then use the overflow-x property set to “scroll” for the entire table.


2 Answers

There's a working example at http://ajaxian.com/archives/freeze-pane-functionality that should be easy to duplicate. Be sure to note the comments -- many of the users have made helpful suggestions for improving the script.

Per @Nirk's request, a direct link to the active demo is at http://www.disconova.com/open_source/files/freezepanes.htm.

like image 199
anschauung Avatar answered Nov 12 '22 06:11

anschauung


Go with a basic structure like this-

table
  row
    column (blank)
    column
      table (1 row high, column headers)
  row
    column 
      table (1 column wide, row headers)
    column
      div (fixed height & width, overflow auto)
        table (actual data)

Set a fixed table-layout and specify column widths in pixels explicitly. You should be able to achieve the same effect.

like image 34
Chetan S Avatar answered Nov 12 '22 08:11

Chetan S