trtablesorter
v1.0.0
Published
JS Plugin to sort a table.
Downloads
2
Readme
Tablesorter
JavaScript Plugin to sort Tables.
Documentation
| Option | Description | Type | Example | Required |
| --- | --- | --- | --- | --- |
tableWrapper | The wrapper of the table. | DOM Element | | Yes
tableHeaderClass | The class of the table header. (with dot at front) | String | '.table-header' | Yes
tableBodyClass | The class of the table body. (with dot at front) | String | '.table-body' | Yes
tableRowClass | The class of the table rows. (with dot at front) | String | '.table-row' | Yes
tableColClass | The class of the table column. (with dot at front) | String | '.td' | Yes
activeStateClass | The class of the table heading column when it's filtered by this column. (with dot at front) | String | '.current' | No
activeDescClass | The class of the table heading column when it's filtered descending by this column. (with dot at front) | String | '.desc' | No
activeAscClass | The class of the table heading column when it's filtered ascending by this column. (with dot at front) | String | '.asc' | No
oddRowClass | The class of the every odd row. (with dot at front) | String | '.bg-pink' | No
Usage Example
window.onload = function() {
var tablesorter = new Tablesorter();
var tables = document.querySelectorAll('.wrapper-table');
tables.forEach(function(table) {
tablesorter.addTable({
tableWrapper: table,
tableHeaderClass: '.table-header',
tableBodyClass: '.table-body',
tableRowClass: '.table-row',
tableColClass: '.td',
activeStateClass: '.current',
activeDescClass: '.desc',
activeAscClass: '.asc',
oddRowClass: '.bg-pink',
});
});
};