SlimTable是一个轻量级(缩小了约2kb)的jQuery插件,它将标准表转换为可排序和可分页的表。
1.包括来自CDN的最新版本的jQuery库。
<script src="/path/to/cdn/jquery.min.js"></script>
2.在jQuery库之后包含jQuery SlimTable插件。
<script src="dist/js/slimtable.min.js"></script> <link rel="stylesheet" href="dist/css/slimtable.css" />
3.在目标HTML表上调用插件。
<table id='example'> <thead> <tr> <th>ID</th> <th>First name</th> <th>Last name</th> <th>Age</th> <th>Company</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Alisa</td> <td>Smith</td> <td>34</td> <td>Unemployed</td> </tr> <tr> <td>2</td> <td>Eamon</td> <td>Jones</td> <td>26</td> <td>Example corp</td> </tr> <tr> <td>3</td> <td>David</td> <td>Brown</td> <td>22</td> <td>Example corp</td> </tr> <tr> <td>4</td> <td>Joseph</td> <td>Taylor</td> <td>43</td> <td>Example corp</td> </tr> <tr> <td>5</td> <td>Thomas</td> <td>Moore</td> <td>67</td> <td>Nextgen corp</td> </tr> <tr> <td>6</td> <td>Daniel</td> <td>White</td> <td>19</td> <td>Unemployed</td> </tr> <tr> <td>7</td> <td>Steven</td> <td>Harris</td> <td>38</td> <td>Nextgen corp</td> </tr> <tr> <td>8</td> <td>Brian</td> <td>Clark</td> <td>82</td> <td>Metalking</td> </tr> <tr> <td>9</td> <td>Kevin</td> <td>Lewis</td> <td>71</td> <td>Metalking</td> </tr> <tr> <td>10</td> <td>Jason</td> <td>Allen</td> <td>58</td> <td>Example corp</td> </tr> <tr> <td>11</td> <td>Mary</td> <td>Walker</td> <td>32</td> <td>Prevgen</td> </tr> <tr> <td>12</td> <td>Lisa</td> <td>Young</td> <td>33</td> <td>Example corp</td> </tr> <tr> <td>13</td> <td>Nancy</td> <td>King</td> <td>64</td> <td>Fakecorp</td> </tr> <tr> <td>14</td> <td>Brian</td> <td>White</td> <td>38</td> <td>Prevgen</td> </tr> <tr> <td>15</td> <td>Stewen</td> <td>Lewis</td> <td>22</td> <td>Fakecorp</td> </tr> </tbody> </table>
$(function() { $("#example").slimtable(); });
4.所有默认插件设置。
$("#example").slimtable({ // dynamic HTML data tableData: null, dataUrl: null, itemsPerPage: 10, ippList: [5,10,20], pagingStart: 0, keepAttrs: [], sortList: [], // { colNumber: 0, enableSort: false, addClasses: [ 'customclass1' ] } colSettings: [], text1: "items/page", text2: "Loading...", // callbacks sortStartCB: null, sortEndCB: null });
v2.0.0版本(2023-01-05)
v1.3.3(2016年3月15日)
v1.3.0(2016年3月14日)
v1.2.7 (2016-03-07)
v1.2.6 (2016-03-07)
v1.2.5 (2015-06-03)
v1.2.3 (2015-06-03)
v1.2.2 (2015-05-28)
v1.1.3 (2013-08-18)