Skip to content

Instantly share code, notes, and snippets.

@gon250
Created April 27, 2015 09:22
Show Gist options
  • Save gon250/1b299928609fa1aa99db to your computer and use it in GitHub Desktop.
Save gon250/1b299928609fa1aa99db to your computer and use it in GitHub Desktop.
tablesorter
$(document).ready(function () {
$.tablesorter.themes.bootstrap = {
// these classes are added to the table. To see other table classes available,
// look here: http://getbootstrap.com/css/#tables
table: 'table table-bordered table-striped',
caption: 'caption',
// header class names
header: 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
sortNone: '',
sortAsc: '',
sortDesc: '',
active: '', // applied when column is sorted
hover: '', // custom css required - a defined bootstrap style may not override other classes
// icon class names
icons: '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
iconSortNone: 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
iconSortAsc: 'icon-chevron-up glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
iconSortDesc: 'icon-chevron-down glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
filterRow: '', // filter row class
footerRow: '',
footerCells: '',
even: '', // even row zebra striping
odd: '' // odd row zebra striping
};
// call the tablesorter plugin and apply the uitheme widget
$("table").tablesorter({
theme: "bootstrap",
widthFixed: true,
headers: { 5: { sorter: false, filter: false }, 7: { sorter: false, filter: false } },
headerTemplate: '{content} {icon}',
widgets: ["uitheme", "filter", "zebra"],
widgetOptions: {
zebra: ["even", "odd"],
filter_reset: ".reset"
}
})
.tablesorterPager({
container: $(".ts-pager"),
cssGoto: ".pagenum",
removeRows: false,
output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'
});
});
<tfoot>
<tr role="row">
<th colspan="7" class="ts-pager form-horizontal tablesorter-pager" data-column="0">
<button type="button" class="btn first disabled" tabindex="0" aria-disabled="true"><i class="icon-step-backward glyphicon glyphicon-step-backward"></i></button>
<button type="button" class="btn prev disabled" tabindex="0" aria-disabled="true"><i class="icon-arrow-left glyphicon glyphicon-backward"></i></button>
<span class="pagedisplay">1 - 10 / 50 (50)</span> <!-- this can be any element, including an input -->
<button type="button" class="btn next" tabindex="0" aria-disabled="false"><i class="icon-arrow-right glyphicon glyphicon-forward"></i></button>
<button type="button" class="btn last" tabindex="0" aria-disabled="false"><i class="icon-step-forward glyphicon glyphicon-step-forward"></i></button>
<select class="pagesize input-mini" title="Select page size" aria-disabled="false">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
<select class="pagenum input-mini" title="Select page number" aria-disabled="false"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select>
</th>
</tr>
</tfoot>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment