npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-table-wrapper

v1.0.3

Published

A standalone sort/filter utility for HTMLTableElements.

Downloads

8

Readme

HTMLTableWrapper.js

HTMLTableWrapper.js is a standalone, lightweight, completely pluggable library for user-defined sorting and filtering of HTMLTableElements following the typical vertical layout. The easiest way to get up-and- running with HTMLTableWrapper.js is to use its full configuration:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper.min.css" />
<script src="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    'use strict';
    
    new HTMLTableWrapperListener(document.getElementById('myTable')).init();
});
</script>

Or, if you prefer to trigger sorting and filtering directly, the utility or core configurations are sufficient (utility shown below):

<link rel="stylesheet" 
        href="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper-util.min.css" />
<script src="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper-util.min.js"></script>
<script>
var tableWrapper;
document.addEventListener('DOMContentLoaded', function () {
    'use strict';
    
    tableWrapper = new HTMLTableWrapper(document.getElementById('myTable'));
});
</script>
<!-- ... -->
<script>
// Some event handler
    // Sort by column index 2, asc and 3, desc.
    tableWrapper.sort(new SimpleSortDescriptor(2), new SimpleSortDescriptor(3, true));
    // Filter column index 0 to include only values greater than or equal to 3.
    tableWrapper.sort(new SimpleFilterDescriptor(0, 3, '>='));
</script>

Installation

To use HTMLTableWrapper.js on your webpages, you need only include the desired combination of JavaScript/CSS files shown beloww:

  • Full
    • html-table-wrapper.min.js
    • html-table-wrapper.min.css
    Fully featured, and end-user friendly, this is the easiest configuration to use.
  • Utility
    • html-table-wrapper-util.min.js
    • html-table-wrapper-util.min.css
    The core configuration with extra classes and functions to assist in using HTMLTableWrapper.js. No UI-related classes are included.
  • Core
    • html-table-wrapper-core.min.js
    • html-table-wrapper-core.min.css
    Includes only the definition of HTMLTableWrapper and supporting compatibility functions for Internet Explorer.

All files are included in the NPM package. If you use NPM, these can be installed in your local project via:

> npm i html-table-wrapper

The desired files can then be copied/linked from your ./node_modules/html-table-wrapper/ directory.

Alternatively, the desired files can be linked to or downloaded directly via the JSDelivr CDN (all examples link directly to the CDN):

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper[-util|-core].min.css" />
<script src="https://cdn.jsdelivr.net/npm/html-table-wrapper/html-table-wrapper[-util|-core].min.js"></script>

Compatibility

HTMLTableWrapper.js is compatible with modern desktop and mobile browsers, as well as with MS Internet Explorer back to version 8.

Documentation

The API Documentation is shipped in the /doc directory of the NPM package, and can also be found here.

Because all declarations in HTMLTableWrapper.js are made in the strictly 'traditional' manner, all constructors, functions, and fields are fully accessible by client code. For this reason, all declared members are documented, however, client code should only rely on those members declared public. Anything labeled private, package, etc. can be used, but may be subject to change without notice.

This project's documentation is generated with JSDoc and hosted on GitHub Pages.

Usage Examples

Links to the examples and working webpages are provided below.

Although HTMLTableWrapper.js is compatible with IE back to version 8, the examples are not. They require a modern browser with an up-to-date DOM and ECMAScript implementation. Due to the relative novelty of ES6+ syntax elements, the examples use pre-ES6 syntax.

If you prefer the newer ES6+ syntax, a version of each example source file written in this syntax is provided with a -es6.js suffix. These will be kept up-to-date as possible with the ECMA-262 latest draft.

A Simple Table

Example using the full configuration:

Changing Cell Interpretation

Example using a CellInterpreter:

Defining Custom Controls

Example using a ColumnControl:

Using HTMLTableWrapper Directly

Example using the utility configuration.

Programming For HTMLTableWrapper

Example of using the core configuration.

Administrivia

License

HTMLTableWrapper.js is licenced under the MIT and BSD 3-Clause Free Software Licenses. A full copy can be found here.

Reporting Issues

Please report any issues or bugs encountered using HTMLTableWrapper.js through this repository's issues section.

Contributing

If you'd like to develop an enhancement, or fix a bug yourself, please fork this repository, make your change, and submit a pull request.

We ask that pull requests contain only changes to the HTMLTableWrapper.js library itself. If you're developing a plugin to it, please create and maintain your own repositry, and simply list HTMLTableWrapper.js as a dependency.

Building

HTMLTableWrapper.js uses Gulp to build its distribution package. If you do not have Gulp installed on your machine, you can do so through NPM (distributed with node.js):

> npm i -g gulp-cli

Development dependencies are also installed with NPM. From your cloned repository's root directory, run:

> npm i

The distribution package can then be built using the default Gulp task:

> gulp

After running Gulp, a new subdirectory will be created: html-table-wrapper. This subdirectory is the "distribution" package.