The jquery.freezetable plugin freezes the header row of a table and adds a scroll bar to allow a long table to be scrolled vertically.

View Demos

Download

Download FreezeTable from GitHub

Instructions & Help

The table markup needs to adhere to the HTML 4.01 Specification for Tables. The row groups THEAD and TBODY are used to determine which sections of the table should be frozen. jquery.freezetable clones the table and removes the TBODY from the cloned copy to ‘freeze’ the header. It then removes the THEAD from the original table to make the scrollable portion of the table. jquery.freezetable also depends on COLGROUP to maintain consistent column styling between the original and cloned header table.

Expected <table> markup

<table id="mytable">
  <colgroup>
    <col class="column-make" />
    <col class="column-display" />
    <col class="column-country" />       
  </colgroup>
  <thead>
    <tr>
      <th>make_id</th>
      <th>make_display</th>
      <th>make_country</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>abarth</td>
      <td>Abarth</td>
      <td>Italy</td>
    </tr>
  </tbody>
</table>

Usage

$(document).ready(function () {
    $('#mytable').freezeTable({
        'autoHeight': false,
        'height': 160
    });
});

Settings

height
Integer – The height of the scrollable part of the table. Only used when ‘autoHeight’ is true.
Default: 480
scrollbarWidth
Integer – The width of the area to the right of the table reserved for the scrollbar.
Default: 20
autoHeight
Boolean – When ‘true’ the scrollable section of the table will streach to fill the browser window.
When ‘false’ the scollable section of the table will determined by the ‘height’ option.
Default: false
autoHeightMarginBottom
Integer – The size of the margin between the bottom of the browser window and the table when ‘autoHeight’ is true.
Default: 20

Leave a Reply

  • (will not be published)