1.0.0 • Published 4 years ago

trtablesorter v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Tablesorter

JavaScript Plugin to sort Tables.

Documentation

OptionDescriptionTypeExampleRequired
tableWrapperThe wrapper of the table.DOM ElementYes
tableHeaderClassThe class of the table header. (with dot at front)String'.table-header'Yes
tableBodyClassThe class of the table body. (with dot at front)String'.table-body'Yes
tableRowClassThe class of the table rows. (with dot at front)String'.table-row'Yes
tableColClassThe class of the table column. (with dot at front)String'.td'Yes
activeStateClassThe class of the table heading column when it's filtered by this column. (with dot at front)String'.current'No
activeDescClassThe class of the table heading column when it's filtered descending by this column. (with dot at front)String'.desc'No
activeAscClassThe class of the table heading column when it's filtered ascending by this column. (with dot at front)String'.asc'No
oddRowClassThe 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',
    });
  });
};