jQuery Plugin To Create Scrollable HTML Table Table Scroller - Free Download Dynamic Scrollable Sortable Table In jQuery - tableScroller

Free Download Dynamic Scrollable Sortable Table In jQuery – tableScroller

Posted on

This time I will share jQuery Plugin and tutorial about Dynamic Scrollable Sortable Table In jQuery – tableScroller, hope it will help you in programming stack.

table scroller - Free Download Dynamic Scrollable Sortable Table In jQuery - tableScroller
File Size: 5.8 KB
Views Total: 1244
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

tableScroller is a tiny jQuery table generator plugin that dynamically generates a responsive, sortable and scrollable HTML table from an array of JS objects or JSON data.

It provides a simple and user-friendly solution to represent large tabular data on the web.

How to use it:

1. Download and place the JavaScript library tableScroller.js after loading jQuery.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/local/tableScroller.js"></script>

2. Define your tabular data in a JavaScript array as follows:

01 let myData =  [
02     {
03       "id": 1,
04       "firstname": "Mark",
05       "lastname": "Otto",
06     },
07     {
08       "id": 2,
09       "firstname": "Jacob",
10       "lastname": "Thornton"
11     },
12     ,
13     {
14       "id": 3,
15       "firstname": "Larry",
16       "lastname": "the Bird"
17     },
18     // more tabular data here
19 ];

3. Insert the table header and an empty tbody to your HTML table.

  • data-prop: key prop
  • data-way: sort data in either ascending or descending order
01 <table id="tableScroller">
02   <thead>
03     <tr>
04       <th data-prop="id" data-way="up">Id</th>
05       <th data-prop="firstname" data-way="up">First name</th>
06       <th data-prop="lastname" data-way="up">Last name</th>
07     </tr>
08   </thead>
09   <tbody>
10   </tbody>
11 </table>

4. Populate the tbody with your data and specify the max height of the HTML table. That’s it.

1 let myTable = $("#tableScroller").tableScroller("init",{
2     "data": data,
3     "options": {
4       "tbodyHeight": "250px"
5     }
6 });

5. Customize the sort indicator displayed in the th cells.

01 table th{
02   cursor:pointer;
03   user-select: none;
04 }
05  
06 table th[data-way]:after{
07   content: "f0dc";
08   font-family: 'Font Awesome 5 Free';
09   float:right;
10 }

This awesome jQuery plugin is developed by PhilippeMarcMeyer. For more Advanced Usages, please check the demo page or visit the official website.

source : jquery.net