Notes

  • IMPORTANT If using jQuery versions older than 1.8, css box-sizing for the table MUST be set as box-sizing: content-box; or the resizable widget will not work properly.
  • IMPORTANT The resize div ends up with a zero height if the header cell is empty. Please include at least a   in the cell to allow it to render properly (ref).

  • In v2.22.2, resizable will now work with tables inside an overflow wrapper (see issue #953).
  • In v2.21.5, this widget now works with the columnSelector widget & tables with margins (see issue #864).
  • In v2.21.3
    • Performed a major overhaul on the resizable widget to add resizable handles outside of the table, so now the resizable handles can be used over the entire height of the table!
    • This change allows the resizable widget to work seemlessly with the stickyHeaders widget (included in this demo); sadly, to make it work with the scroller widget will require more work.
  • In v2.17.4, modified the bindings so the mouse move will now work on the document instead of only within the table header; this makes interaction consistent with what the user expects.
  • In v2.15.12, added resizable_widths option which allows the setting of default & reset header widths.
  • As of tablesorter version 2.9+, this widget can no longer be applied to versions of tablesorter prior to version 2.8.
  • This widget now saves all changed column widths to local storage, or it falls back to a cookie! (v2.1)
  • Column width saving requires the new "$.tablesorter.storage()" function included with the "jquery.tablesorter.widgets.js" file (v2.1).
  • Right clicking (opening the context menu) will now reset the resized columns (v2.4).
  • Holding down the shift key while resizing will force the last column or the table to resize instead of the next column, but only if the table is full width (v2.7.4).
  • Prevent resizing a column by adding any of the following (they all do the same thing), set in order of priority (v2.7.4):
    • jQuery data data-resizable="false".
    • metadata class="{ resizable: 'false'}". This requires the metadata plugin.
    • headers option headers : { 0 : { resizable : 'false' } }.
    • header class name class="resizable-false".
  • Setting the resizable widget option to false, will only prevent the saving of resized columns, it has nothing to do with preventing a column from being resized.
  • Because this widget uses jQuery's closest() (jQuery 1.3+) and index() (jQuery 1.4+) functions, it requires these newer versions of jQuery in order to work.
  • In order to save the resized widths, jQuery version 1.4.1+ should be used because jQuery's parseJson() function is needed.
  • Setting the resizable_addLastColumn widget option to true will add the resizable handle to the last column, see the "non-full" width table below (v2.9.0).

Options

Resizable widget defaults (added inside of tablesorter widgetOptions)

TIP! Click on the link in the function column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
OptionDefaultDescription
true When true and the storage widget is included, all column widths will be saved to storage.

This means that when the page is reloaded, any adjusted column widths will be restored.

The adjusted column sizes can be reset at any time by right-clicking on the table header.

false When true, the last column of the table is made resizable.

If the table is full width, adjusting the right edge would actually shrink or stretch all columns without moving the right border.

On narrower tables, the table width will be adjusted.

[ ] Set any default column widths within this zero-based-column-indexed array

This option allows the setting of column widths initially (before any resizing occurs, or if there are no saved column widths) and when resetting (right-click on the column header).

The array may contain any css allowed width definitions (e.g. percentage, pixels, em, etc).

Undefined column widths to not add a specified width to the column

Here is an example from the second table in this demo showing how to set this option:

// Note that the "Age" column is not resizable,
// but the width can still be set to 40px here
resizable_widths : [ '10%', '10%', '40px', '10%', '100px' ]
false When this option is set to a number, or true, the resizing event from the window is throttled.

Essentially, throttling the resize event limits the number of times the javascript is executed while resizing the window.

Without any throttling, slower browsers may lag while the javascript adjusts the column widths of the table.

With excessive throttling, the user will notice the table column width lag (while will be seen as the width jumping sporatically to catch up to the mouse) behind the mouse movement.

When this option is set to true, a default of 5 (milliseconds) is used.

If setting a number, try to keep this number in the 0 to 10 range.

false When true, the last column will be targeted for resizing.

When true, resizing a column will change the size of the selected column, and the last column, not the selected column's neighbor.

When false, resizing a column will move the column border between it's neighbors.

Also, in a full width table, if this option is false, the same behavior as when this option is true can be seen when resizing a column while holding down the Shift key on the keyboard - the last column is resized.

Demo

Non-full width table (individual columns resize)

First Name Last Name Age Total Discount Date
PeterParker28$9.9920%Jul 6, 2006 8:14 AM
JohnHood33$19.9925%Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jan 18, 2007 9:12 AM
Resized values for this table are saved to session storage - values are lost once the browser is closed.

Overflow table (text-overflow: ellipsis set)

First Name Last Name Age Total Discount Date
PeterParker28$9.9920%Jul 6, 2006 8:14 AM
JohnHood33$19.9925%Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jan 18, 2007 9:12 AM

Full width table (use shift to force last column to resize)

First Name Last Name Age Total Discount Date
PeterParker28$9.9920%Jul 6, 2006 8:14 AM
JohnHood33$19.9925%Dec 10, 2002 5:14 AM
ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
BruceEvans22$13.1911%Jan 18, 2007 9:12 AM
Resized values for this table are saved to local storage - values are not lost once the browser is closed.

Page Header

<!-- blue theme stylesheet with additional css styles added in v2.0.17 -->
<link rel="stylesheet" href="../css/theme.blue.css">
<!-- tablesorter plugin -->
<script src="../js/jquery.tablesorter.js"></script>

<!-- tablesorter widget file - loaded after the plugin -->
<script src="../js/jquery.tablesorter.widgets.js"></script>

CSS


	

Javascript


	

HTML

<!-- The Age column is set to not be resizable -->
<table class="tablesorter" style="width:auto">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th class="resizable-false">Age</th>
      <th>Total</th>
      <th>Discount</th>
      <th>Date</th>
    </tr>
  </thead>
  <tbody>
    ...
  </tbody>
</table>

Next up: Applying the save sort widget ››