• 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 resizable will not work properly if the widthFixed option is set to true. Make sure it is set to false (default setting).
  • 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). No longer necessary as the resizable widget no longer adds elements inside the table header cells.

  • In v2.29.0, added a resizableComplete event.
  • In v2.28.8, added the resizable_includeFooter option.
  • In v2.28.5,
    • A resizableUpdate event can be triggered on the table to update the resizable handles.
    • A resizableReset event can be triggered to reset the resizable columns to their default widths.
  • 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).

Demo

Non-full width table (individual columns resize)

First Name
Last Name
Age
Total
Discount
Date
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

th.tablesorter-header.resizable-false {
background-color: #e6bf99;
}
/* ensure box-sizing is set to content-box, if using jQuery versions older than 1.8;
this page is using jQuery 1.4 */
*, *:before, *:after {
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
/* overflow table */
.wrapper {
overflow-x: auto;
overflow-y: hidden;
width: 450px;
}
.wrapper table {
width: auto;
table-layout: fixed;
}
.wrapper .tablesorter td {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 10px;
}
.wrapper .tablesorter th {
overflow: hidden;
text-overflow: ellipsis;
min-width: 10px;
}

Javascript

$(function() {

$('.narrow-table').tablesorter({
theme : 'blue',
// initialize zebra striping and resizable widgets on the table
widgets: [ 'zebra', 'resizable', 'stickyHeaders' ],
widgetOptions: {
// storage_useSessionStorage : true, deprecated in v2.28.8
storage_storageType: 's', // use first letter (s)ession
resizable_addLastColumn : true
}
});

// overflow table
$('.wrapper table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'resizable'],
widgetOptions: {
resizable_addLastColumn : true,
resizable_widths : [ '100px', '60px', '30px', '50px', '60px', '140px' ]
}
});

$('.full-width-table').tablesorter({
theme : 'blue',
// initialize zebra striping and resizable widgets on the table
widgets: [ 'zebra', 'resizable', 'stickyHeaders' ],
widgetOptions: {
resizable: true,
// These are the default column widths which are used when the table is
// initialized or resizing is reset; 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' ]
}
});

});

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 ››