- Clone the github repository
-
Include the stylesheet and JavaScript files from the
distfolder:<link rel="stylesheet" type="text/css" href="/dist/jstable.css"> <script type="text/javascript" src="/dist/jstable.min.js"></script> -
If the target browser does not support not all ES2015+ features you need to include the
es5version:<script type="text/javascript" src="/dist/jstable.es5.min.js"></script> -
If the target browser does not support fetch you need to include the following polyfills:
<script type="text/javascript" src="/dist/polyfill-fetch.min.js"></script>
Install
Initialize
The HTML table needs a thead and tbody section.
Example table
<table id="basic">
<thead>
<tr>
<th>Name</th>
<th>Country</th>
<th>Date</th>
<th>Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>Norman Small</td>
<td>Tokelau</td>
<td>2020-02-01 07:22:40</td>
<td>8243</td>
</tr>
...
</tbody>
</table>
JavaScript
The JSTable can be initialized by passing a reference or a CSS3 selector as string:
let myTable = new JSTable("#basic");
or
let table = document.getElementById('basic');
let myTable = new JSTable(table);
Options can be passed as second argument:
let myTable = new JSTable("#basic", {
sortable: true,
searchable: false,
...
});
Result
| Name | Country | Date | Number |
|---|---|---|---|
| Rhona Carey | Northern Mariana Islands | 2020-03-12 03:47:43 | 9761 |
| Ria Sherman | Denmark | 2019-07-16 18:36:14 | 7472 |
| Hoyt Delgado | Tajikistan | 2019-11-26 15:47:50 | 7470 |
| Bernard Murray | Sint Maarten | 2019-09-25 21:14:41 | 2793 |
| Arden House | Armenia | 2019-01-08 09:02:02 | 9055 |
| Nina Ferrell | Palau | 2019-09-17 08:16:39 | 5120 |
| Glenna Shannon | Malta | 2019-09-30 03:22:10 | 5166 |
| Erica Grant | Saint Kitts and Nevis | 2019-11-12 02:18:39 | 1025 |
| Simon Cardenas | Cayman Islands | 2019-08-25 11:31:53 | 2766 |
| Joy Brennan | Ireland | 2019-05-18 01:31:41 | 9680 |
| Kennedy Arnold | Uganda | 2019-08-18 12:37:04 | 3043 |
| Baxter Rutledge | Faroe Islands | 2018-08-08 19:03:44 | 2476 |
| Willa Cook | Micronesia | 2019-04-24 17:16:02 | 1026 |
| Sara Fleming | New Caledonia | 2019-09-27 06:48:17 | 3981 |
| Whilemina Whitfield | Sri Lanka | 2018-08-30 20:05:14 | 9917 |
| Tiger Powell | Laos | 2018-11-15 21:26:51 | 7933 |
| Maya Powers | Kenya | 2019-03-21 08:48:02 | 3199 |
| Kermit Campbell | Cambodia | 2019-06-29 03:47:03 | 6323 |
| Kennedy Sears | Thailand | 2019-01-13 05:29:01 | 8502 |
| Aristotle Gallagher | Sao Tome and Principe | 2019-04-14 13:28:58 | 5982 |
| Rahim Ortega | Haiti | 2019-05-15 02:45:11 | 4386 |
| Abigail Conway | Wallis and Futuna | 2018-11-28 02:09:58 | 4243 |
| Calvin Harding | Switzerland | 2019-01-26 02:41:56 | 9560 |
| Nissim Owen | South Africa | 2019-05-18 22:24:41 | 2985 |
| Edan Oneill | Sweden | 2018-11-25 07:18:01 | 3439 |
| Simon Reese | Lesotho | 2019-05-09 14:24:04 | 8611 |
| Kylee Herrera | Kazakhstan | 2020-03-28 06:08:52 | 8434 |
| Melvin Stafford | Bonaire, Sint Eustatius and Saba | 2018-09-17 10:39:37 | 9539 |
| Regan Allen | Greenland | 2020-01-13 15:54:15 | 8614 |
| Castor Kelley | Cameroon | 2019-05-19 11:11:10 | 1703 |
| Hamilton Durham | Bulgaria | 2019-06-22 09:46:17 | 6432 |
| Carl Burch | Bouvet Island | 2020-04-08 07:09:33 | 4149 |
| Hiroko Finley | Nigeria | 2020-02-11 07:20:14 | 2620 |
| Fatima Miles | Libya | 2020-06-12 19:04:07 | 5222 |
| Sylvia Lane | Dominican Republic | 2019-08-06 01:30:45 | 1857 |
| Maggie Sawyer | Åland Islands | 2019-12-01 23:56:22 | 2825 |
| Dominique Lang | Nigeria | 2019-07-30 00:11:31 | 1829 |
| Wayne Shepherd | Singapore | 2019-12-02 14:16:56 | 1289 |
| Oren Wiley | Northern Mariana Islands | 2020-01-21 01:23:54 | 8272 |
| Hayden Dale | Sierra Leone | 2019-10-18 09:36:02 | 6573 |
| Rhona Mullen | Côte D'Ivoire (Ivory Coast) | 2018-09-06 19:06:03 | 8237 |
| Hector Hamilton | Mauritania | 2018-08-30 14:08:34 | 8929 |
| Edan Sexton | French Southern Territories | 2020-05-25 18:01:10 | 6034 |
| Rhea Monroe | Syria | 2018-10-23 13:11:54 | 7473 |
| Emerald Clay | Martinique | 2020-02-28 19:11:24 | 9108 |
| Griffin Dillon | Saudi Arabia | 2018-11-07 16:43:16 | 5947 |
| Autumn Clay | Laos | 2020-03-14 07:57:07 | 5049 |
| Rahim Vance | Samoa | 2020-05-03 05:32:40 | 5926 |
| Hammett Levine | Martinique | 2020-01-06 00:53:12 | 5589 |
| Yardley Fisher | Sierra Leone | 2018-09-04 04:05:40 | 3460 |