flowbite-mcp 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -74
- package/build/index.js +20 -36
- package/data/components/accordion.md +39 -53
- package/data/components/alerts.md +27 -44
- package/data/components/avatar.md +20 -33
- package/data/components/badge.md +34 -47
- package/data/components/banner.md +10 -29
- package/data/components/bottom-navigation.md +16 -29
- package/data/components/breadcrumb.md +12 -25
- package/data/components/button-group.md +26 -39
- package/data/components/buttons.md +41 -67
- package/data/components/card.md +34 -47
- package/data/components/carousel.md +25 -39
- package/data/components/chat-bubble.md +36 -50
- package/data/components/clipboard.md +256 -252
- package/data/components/datepicker.md +56 -70
- package/data/components/device-mockups.md +16 -29
- package/data/components/drawer.md +42 -56
- package/data/components/dropdowns.md +66 -80
- package/data/components/footer.md +16 -29
- package/data/components/forms.md +32 -50
- package/data/components/gallery.md +16 -33
- package/data/components/indicators.md +18 -31
- package/data/components/jumbotron.md +12 -25
- package/data/components/kbd.md +14 -27
- package/data/components/list-group.md +14 -27
- package/data/components/mega-menu.md +10 -24
- package/data/components/modal.md +37 -51
- package/data/components/navbar.md +41 -55
- package/data/components/pagination.md +22 -35
- package/data/components/popover.md +36 -51
- package/data/components/progress.md +10 -23
- package/data/components/qr-code.md +41 -133
- package/data/components/rating.md +16 -29
- package/data/components/sidebar.md +15 -30
- package/data/components/skeleton.md +16 -29
- package/data/components/speed-dial.md +40 -55
- package/data/components/spinner.md +14 -27
- package/data/components/stepper.md +14 -27
- package/data/components/tables.md +45 -64
- package/data/components/tabs.md +30 -45
- package/data/components/timeline.md +10 -23
- package/data/components/toast.md +25 -39
- package/data/components/tooltips.md +24 -39
- package/data/components/typography.md +22 -35
- package/data/components/video.md +14 -27
- package/data/forms/checkbox.md +27 -43
- package/data/forms/file-input.md +12 -26
- package/data/forms/floating-label.md +12 -25
- package/data/forms/input-field.md +17 -32
- package/data/forms/number-input.md +83 -93
- package/data/forms/phone-input.md +42 -54
- package/data/forms/radio.md +23 -39
- package/data/forms/range.md +12 -26
- package/data/forms/search-input.md +14 -31
- package/data/forms/select.md +15 -30
- package/data/forms/textarea.md +8 -21
- package/data/forms/timepicker.md +30 -42
- package/data/forms/toggle.md +18 -31
- package/data/plugins/charts.md +542 -526
- package/data/plugins/datatables.md +285 -286
- package/data/plugins/wysiwyg.md +658 -650
- package/data/quickstart.md +24 -24
- package/data/typography/blockquote.md +24 -37
- package/data/typography/headings.md +30 -43
- package/data/typography/hr.md +10 -23
- package/data/typography/images.md +32 -45
- package/data/typography/links.md +16 -29
- package/data/typography/lists.md +22 -35
- package/data/typography/paragraphs.md +30 -43
- package/data/typography/text.md +42 -55
- package/package.json +1 -1
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: docs
|
|
3
|
-
title: Tailwind CSS Datatables - Flowbite
|
|
4
|
-
description: Use the datatable component to search, sort, filter, export and paginate table data of rows and columns for your web application coded with the utility classes from Tailwind CSS
|
|
5
|
-
group: plugins
|
|
6
|
-
toc: true
|
|
7
|
-
requires_js: true
|
|
8
|
-
|
|
9
|
-
previous: Charts
|
|
10
|
-
previousLink: plugins/charts/
|
|
11
|
-
|
|
12
|
-
next: WYSIWYG
|
|
13
|
-
nextLink: plugins/wysiwyg/
|
|
14
|
-
---
|
|
15
|
-
|
|
16
1
|
The datatable component examples from Flowbite are open-source under the MIT License and they are based on the [simple-datatables](https://github.com/fiduswriter/simple-datatables) repository from GitHub which you need to install via NPM or CDN.
|
|
17
2
|
|
|
18
3
|
This page provides multiple examples of datatable components where you can search, sort, filter, paginate and export table data up to thousands of entries coded with Tailwind CSS and leveraging JavaScript code provided by the parent library.
|
|
@@ -23,19 +8,19 @@ All examples are responsive, dark mode and RTL support included and by installin
|
|
|
23
8
|
|
|
24
9
|
Before continuing make sure that you have Tailwind CSS, Flowbite, and Simple Datables in your project.
|
|
25
10
|
|
|
26
|
-
1. Install Tailwind CSS and follow our
|
|
11
|
+
1. Install Tailwind CSS and follow our quickstart guide to install Flowbite and the official plugin
|
|
27
12
|
|
|
28
13
|
2. Install the `simple-datatables` library using NPM:
|
|
29
14
|
|
|
30
|
-
|
|
15
|
+
```bash
|
|
31
16
|
npm install simple-datatables --save
|
|
32
|
-
|
|
17
|
+
```
|
|
33
18
|
|
|
34
19
|
Alternatively, you can also include it in your project using CDN:
|
|
35
20
|
|
|
36
|
-
|
|
21
|
+
```html
|
|
37
22
|
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@9.0.3"></script>
|
|
38
|
-
|
|
23
|
+
```
|
|
39
24
|
|
|
40
25
|
Now that you have installed all libraries you can start copy-pasting the datatable components from Flowbite.
|
|
41
26
|
|
|
@@ -45,14 +30,7 @@ Make sure that in addition to the HTML markup you also copy the JavaScript code
|
|
|
45
30
|
|
|
46
31
|
Use this example to show table data with default sorting and pagination functionalities.
|
|
47
32
|
|
|
48
|
-
|
|
49
|
-
if (document.getElementById("default-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
50
|
-
const dataTable = new simpleDatatables.DataTable("#default-table", {
|
|
51
|
-
searchable: false,
|
|
52
|
-
perPageSelect: false
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
` >}}
|
|
33
|
+
```html
|
|
56
34
|
<table id="default-table">
|
|
57
35
|
<thead>
|
|
58
36
|
<tr>
|
|
@@ -219,20 +197,22 @@ if (document.getElementById("default-table") && typeof simpleDatatables.DataTabl
|
|
|
219
197
|
</tr>
|
|
220
198
|
</tbody>
|
|
221
199
|
</table>
|
|
222
|
-
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
if (document.getElementById("default-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
204
|
+
const dataTable = new simpleDatatables.DataTable("#default-table", {
|
|
205
|
+
searchable: false,
|
|
206
|
+
perPageSelect: false
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
```
|
|
223
210
|
|
|
224
211
|
## Table search
|
|
225
212
|
|
|
226
213
|
Set the `searchable` option to `true` to enable the search functionality for all table data.
|
|
227
214
|
|
|
228
|
-
|
|
229
|
-
if (document.getElementById("search-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
230
|
-
const dataTable = new simpleDatatables.DataTable("#search-table", {
|
|
231
|
-
searchable: true,
|
|
232
|
-
sortable: false
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
` >}}
|
|
215
|
+
```html
|
|
236
216
|
<table id="search-table">
|
|
237
217
|
<thead>
|
|
238
218
|
<tr>
|
|
@@ -442,45 +422,22 @@ if (document.getElementById("search-table") && typeof simpleDatatables.DataTable
|
|
|
442
422
|
</tbody>
|
|
443
423
|
</table>
|
|
444
424
|
|
|
445
|
-
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
if (document.getElementById("search-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
429
|
+
const dataTable = new simpleDatatables.DataTable("#search-table", {
|
|
430
|
+
searchable: true,
|
|
431
|
+
sortable: false
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
```
|
|
446
435
|
|
|
447
436
|
## Filtering data
|
|
448
437
|
|
|
449
438
|
To enable filtering data based on a search query for each column you need to copy the custom code from the JavaScript tab and the HTML structure of the table. Enabling search for each individual data column is an advanced way of letting users browse complex data.
|
|
450
439
|
|
|
451
|
-
|
|
452
|
-
if (document.getElementById("filter-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
453
|
-
const dataTable = new simpleDatatables.DataTable("#filter-table", {
|
|
454
|
-
tableRender: (_data, table, type) => {
|
|
455
|
-
if (type === "print") {
|
|
456
|
-
return table
|
|
457
|
-
}
|
|
458
|
-
const tHead = table.childNodes[0]
|
|
459
|
-
const filterHeaders = {
|
|
460
|
-
nodeName: "TR",
|
|
461
|
-
attributes: {
|
|
462
|
-
class: "search-filtering-row"
|
|
463
|
-
},
|
|
464
|
-
childNodes: tHead.childNodes[0].childNodes.map(
|
|
465
|
-
(_th, index) => ({nodeName: "TH",
|
|
466
|
-
childNodes: [
|
|
467
|
-
{
|
|
468
|
-
nodeName: "INPUT",
|
|
469
|
-
attributes: {
|
|
470
|
-
class: "datatable-input",
|
|
471
|
-
type: "search",
|
|
472
|
-
"data-columns": "[" + index + "]"
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
]})
|
|
476
|
-
)
|
|
477
|
-
}
|
|
478
|
-
tHead.childNodes.push(filterHeaders)
|
|
479
|
-
return table
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
` >}}
|
|
440
|
+
```html
|
|
484
441
|
<table id="filter-table">
|
|
485
442
|
<thead>
|
|
486
443
|
<tr>
|
|
@@ -797,21 +754,47 @@ if (document.getElementById("filter-table") && typeof simpleDatatables.DataTable
|
|
|
797
754
|
</tr>
|
|
798
755
|
</tbody>
|
|
799
756
|
</table>
|
|
800
|
-
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
```javascript
|
|
760
|
+
if (document.getElementById("filter-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
761
|
+
const dataTable = new simpleDatatables.DataTable("#filter-table", {
|
|
762
|
+
tableRender: (_data, table, type) => {
|
|
763
|
+
if (type === "print") {
|
|
764
|
+
return table
|
|
765
|
+
}
|
|
766
|
+
const tHead = table.childNodes[0]
|
|
767
|
+
const filterHeaders = {
|
|
768
|
+
nodeName: "TR",
|
|
769
|
+
attributes: {
|
|
770
|
+
class: "search-filtering-row"
|
|
771
|
+
},
|
|
772
|
+
childNodes: tHead.childNodes[0].childNodes.map(
|
|
773
|
+
(_th, index) => ({nodeName: "TH",
|
|
774
|
+
childNodes: [
|
|
775
|
+
{
|
|
776
|
+
nodeName: "INPUT",
|
|
777
|
+
attributes: {
|
|
778
|
+
class: "datatable-input",
|
|
779
|
+
type: "search",
|
|
780
|
+
"data-columns": "[" + index + "]"
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
]})
|
|
784
|
+
)
|
|
785
|
+
}
|
|
786
|
+
tHead.childNodes.push(filterHeaders)
|
|
787
|
+
return table
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
```
|
|
801
792
|
|
|
802
793
|
## Sorting data
|
|
803
794
|
|
|
804
795
|
By setting the value `sortable` to `true` you'll enable all data rows from the datatable to be sortable by clicking on the table column heading. You can also disable it by setting the same option to `false`.
|
|
805
796
|
|
|
806
|
-
|
|
807
|
-
if (document.getElementById("sorting-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
808
|
-
const dataTable = new simpleDatatables.DataTable("#sorting-table", {
|
|
809
|
-
searchable: false,
|
|
810
|
-
perPageSelect: false,
|
|
811
|
-
sortable: true
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
` >}}
|
|
797
|
+
```html
|
|
815
798
|
<table id="sorting-table">
|
|
816
799
|
<thead>
|
|
817
800
|
<tr>
|
|
@@ -972,7 +955,17 @@ if (document.getElementById("sorting-table") && typeof simpleDatatables.DataTabl
|
|
|
972
955
|
</tr>
|
|
973
956
|
</tbody>
|
|
974
957
|
</table>
|
|
975
|
-
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
```javascript
|
|
961
|
+
if (document.getElementById("sorting-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
962
|
+
const dataTable = new simpleDatatables.DataTable("#sorting-table", {
|
|
963
|
+
searchable: false,
|
|
964
|
+
perPageSelect: false,
|
|
965
|
+
sortable: true
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
```
|
|
976
969
|
|
|
977
970
|
## Table pagination
|
|
978
971
|
|
|
@@ -980,16 +973,7 @@ Pagination is enabled by default for all datatables from Flowbite, however, you
|
|
|
980
973
|
|
|
981
974
|
You can also set the `perPageSelect` option to set the selection options of the table.
|
|
982
975
|
|
|
983
|
-
|
|
984
|
-
if (document.getElementById("pagination-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
985
|
-
const dataTable = new simpleDatatables.DataTable("#pagination-table", {
|
|
986
|
-
paging: true,
|
|
987
|
-
perPage: 5,
|
|
988
|
-
perPageSelect: [5, 10, 15, 20, 25],
|
|
989
|
-
sortable: false
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
` >}}
|
|
976
|
+
```html
|
|
993
977
|
<table id="pagination-table">
|
|
994
978
|
<thead>
|
|
995
979
|
<tr>
|
|
@@ -1212,7 +1196,18 @@ if (document.getElementById("pagination-table") && typeof simpleDatatables.DataT
|
|
|
1212
1196
|
</tr>
|
|
1213
1197
|
</tbody>
|
|
1214
1198
|
</table>
|
|
1215
|
-
|
|
1199
|
+
```
|
|
1200
|
+
|
|
1201
|
+
```javascript
|
|
1202
|
+
if (document.getElementById("pagination-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
1203
|
+
const dataTable = new simpleDatatables.DataTable("#pagination-table", {
|
|
1204
|
+
paging: true,
|
|
1205
|
+
perPage: 5,
|
|
1206
|
+
perPageSelect: [5, 10, 15, 20, 25],
|
|
1207
|
+
sortable: false
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
```
|
|
1216
1211
|
|
|
1217
1212
|
## Selecting rows
|
|
1218
1213
|
|
|
@@ -1220,7 +1215,176 @@ Use this example to enable the selection of rows by clicking anywhere one of the
|
|
|
1220
1215
|
|
|
1221
1216
|
Use the `datatable.selectrow` event to write your own code and get the data from the selected table row.
|
|
1222
1217
|
|
|
1223
|
-
|
|
1218
|
+
```html
|
|
1219
|
+
<table id="selection-table">
|
|
1220
|
+
<thead>
|
|
1221
|
+
<tr>
|
|
1222
|
+
<th>
|
|
1223
|
+
<span class="flex items-center">
|
|
1224
|
+
Name
|
|
1225
|
+
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1226
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1227
|
+
</svg>
|
|
1228
|
+
</span>
|
|
1229
|
+
</th>
|
|
1230
|
+
<th data-type="date" data-format="YYYY/DD/MM">
|
|
1231
|
+
<span class="flex items-center">
|
|
1232
|
+
Release Date
|
|
1233
|
+
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1234
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1235
|
+
</svg>
|
|
1236
|
+
</span>
|
|
1237
|
+
</th>
|
|
1238
|
+
<th>
|
|
1239
|
+
<span class="flex items-center">
|
|
1240
|
+
NPM Downloads
|
|
1241
|
+
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1242
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1243
|
+
</svg>
|
|
1244
|
+
</span>
|
|
1245
|
+
</th>
|
|
1246
|
+
<th>
|
|
1247
|
+
<span class="flex items-center">
|
|
1248
|
+
Growth
|
|
1249
|
+
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1250
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1251
|
+
</svg>
|
|
1252
|
+
</span>
|
|
1253
|
+
</th>
|
|
1254
|
+
</tr>
|
|
1255
|
+
</thead>
|
|
1256
|
+
<tbody>
|
|
1257
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1258
|
+
<td class="font-medium text-heading whitespace-nowrap">Flowbite</td>
|
|
1259
|
+
<td>2021/25/09</td>
|
|
1260
|
+
<td>269000</td>
|
|
1261
|
+
<td>49%</td>
|
|
1262
|
+
</tr>
|
|
1263
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1264
|
+
<td class="font-medium text-heading whitespace-nowrap">React</td>
|
|
1265
|
+
<td>2013/24/05</td>
|
|
1266
|
+
<td>4500000</td>
|
|
1267
|
+
<td>24%</td>
|
|
1268
|
+
</tr>
|
|
1269
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1270
|
+
<td class="font-medium text-heading whitespace-nowrap">Angular</td>
|
|
1271
|
+
<td>2010/20/09</td>
|
|
1272
|
+
<td>2800000</td>
|
|
1273
|
+
<td>17%</td>
|
|
1274
|
+
</tr>
|
|
1275
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1276
|
+
<td class="font-medium text-heading whitespace-nowrap">Vue</td>
|
|
1277
|
+
<td>2014/12/02</td>
|
|
1278
|
+
<td>3600000</td>
|
|
1279
|
+
<td>30%</td>
|
|
1280
|
+
</tr>
|
|
1281
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1282
|
+
<td class="font-medium text-heading whitespace-nowrap">Svelte</td>
|
|
1283
|
+
<td>2016/26/11</td>
|
|
1284
|
+
<td>1200000</td>
|
|
1285
|
+
<td>57%</td>
|
|
1286
|
+
</tr>
|
|
1287
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1288
|
+
<td class="font-medium text-heading whitespace-nowrap">Ember</td>
|
|
1289
|
+
<td>2011/08/12</td>
|
|
1290
|
+
<td>500000</td>
|
|
1291
|
+
<td>44%</td>
|
|
1292
|
+
</tr>
|
|
1293
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1294
|
+
<td class="font-medium text-heading whitespace-nowrap">Backbone</td>
|
|
1295
|
+
<td>2010/13/10</td>
|
|
1296
|
+
<td>300000</td>
|
|
1297
|
+
<td>9%</td>
|
|
1298
|
+
</tr>
|
|
1299
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1300
|
+
<td class="font-medium text-heading whitespace-nowrap">jQuery</td>
|
|
1301
|
+
<td>2006/28/01</td>
|
|
1302
|
+
<td>6000000</td>
|
|
1303
|
+
<td>5%</td>
|
|
1304
|
+
</tr>
|
|
1305
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1306
|
+
<td class="font-medium text-heading whitespace-nowrap">Bootstrap</td>
|
|
1307
|
+
<td>2011/19/08</td>
|
|
1308
|
+
<td>1800000</td>
|
|
1309
|
+
<td>12%</td>
|
|
1310
|
+
</tr>
|
|
1311
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1312
|
+
<td class="font-medium text-heading whitespace-nowrap">Foundation</td>
|
|
1313
|
+
<td>2011/23/09</td>
|
|
1314
|
+
<td>700000</td>
|
|
1315
|
+
<td>8%</td>
|
|
1316
|
+
</tr>
|
|
1317
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1318
|
+
<td class="font-medium text-heading whitespace-nowrap">Bulma</td>
|
|
1319
|
+
<td>2016/24/10</td>
|
|
1320
|
+
<td>500000</td>
|
|
1321
|
+
<td>7%</td>
|
|
1322
|
+
</tr>
|
|
1323
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1324
|
+
<td class="font-medium text-heading whitespace-nowrap">Next.js</td>
|
|
1325
|
+
<td>2016/25/10</td>
|
|
1326
|
+
<td>2300000</td>
|
|
1327
|
+
<td>45%</td>
|
|
1328
|
+
</tr>
|
|
1329
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1330
|
+
<td class="font-medium text-heading whitespace-nowrap">Nuxt.js</td>
|
|
1331
|
+
<td>2016/16/10</td>
|
|
1332
|
+
<td>900000</td>
|
|
1333
|
+
<td>50%</td>
|
|
1334
|
+
</tr>
|
|
1335
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1336
|
+
<td class="font-medium text-heading whitespace-nowrap">Meteor</td>
|
|
1337
|
+
<td>2012/17/01</td>
|
|
1338
|
+
<td>1000000</td>
|
|
1339
|
+
<td>10%</td>
|
|
1340
|
+
</tr>
|
|
1341
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1342
|
+
<td class="font-medium text-heading whitespace-nowrap">Aurelia</td>
|
|
1343
|
+
<td>2015/08/07</td>
|
|
1344
|
+
<td>200000</td>
|
|
1345
|
+
<td>20%</td>
|
|
1346
|
+
</tr>
|
|
1347
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1348
|
+
<td class="font-medium text-heading whitespace-nowrap">Inferno</td>
|
|
1349
|
+
<td>2016/27/09</td>
|
|
1350
|
+
<td>100000</td>
|
|
1351
|
+
<td>35%</td>
|
|
1352
|
+
</tr>
|
|
1353
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1354
|
+
<td class="font-medium text-heading whitespace-nowrap">Preact</td>
|
|
1355
|
+
<td>2015/16/08</td>
|
|
1356
|
+
<td>600000</td>
|
|
1357
|
+
<td>28%</td>
|
|
1358
|
+
</tr>
|
|
1359
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1360
|
+
<td class="font-medium text-heading whitespace-nowrap">Lit</td>
|
|
1361
|
+
<td>2018/28/05</td>
|
|
1362
|
+
<td>400000</td>
|
|
1363
|
+
<td>60%</td>
|
|
1364
|
+
</tr>
|
|
1365
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1366
|
+
<td class="font-medium text-heading whitespace-nowrap">Alpine.js</td>
|
|
1367
|
+
<td>2019/02/11</td>
|
|
1368
|
+
<td>300000</td>
|
|
1369
|
+
<td>70%</td>
|
|
1370
|
+
</tr>
|
|
1371
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1372
|
+
<td class="font-medium text-heading whitespace-nowrap">Stimulus</td>
|
|
1373
|
+
<td>2018/06/03</td>
|
|
1374
|
+
<td>150000</td>
|
|
1375
|
+
<td>25%</td>
|
|
1376
|
+
</tr>
|
|
1377
|
+
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1378
|
+
<td class="font-medium text-heading whitespace-nowrap">Solid</td>
|
|
1379
|
+
<td>2021/05/07</td>
|
|
1380
|
+
<td>250000</td>
|
|
1381
|
+
<td>80%</td>
|
|
1382
|
+
</tr>
|
|
1383
|
+
</tbody>
|
|
1384
|
+
</table>
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
```javascript
|
|
1224
1388
|
if (document.getElementById("selection-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
1225
1389
|
|
|
1226
1390
|
let multiSelect = true;
|
|
@@ -1285,8 +1449,14 @@ if (document.getElementById("selection-table") && typeof simpleDatatables.DataTa
|
|
|
1285
1449
|
|
|
1286
1450
|
resetTable();
|
|
1287
1451
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
## Export files
|
|
1455
|
+
|
|
1456
|
+
If you want to enable the export of the table data, you can use the `simpleDatatables.exportCSV` function to export the data as a CSV file. The option is also available for TXT, JSON, and SQL formats.
|
|
1457
|
+
|
|
1458
|
+
```html
|
|
1459
|
+
<table id="export-table">
|
|
1290
1460
|
<thead>
|
|
1291
1461
|
<tr>
|
|
1292
1462
|
<th>
|
|
@@ -1452,13 +1622,9 @@ if (document.getElementById("selection-table") && typeof simpleDatatables.DataTa
|
|
|
1452
1622
|
</tr>
|
|
1453
1623
|
</tbody>
|
|
1454
1624
|
</table>
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
## Export files
|
|
1625
|
+
```
|
|
1458
1626
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
{{< example class="dark:bg-gray-900" github="plugins/datatables.md" show_dark=true datatables=true disable_init_js=true javascript=`
|
|
1627
|
+
```javascript
|
|
1462
1628
|
if (document.getElementById("export-table") && typeof simpleDatatables.DataTable !== 'undefined') {
|
|
1463
1629
|
|
|
1464
1630
|
const exportCustomCSV = function(dataTable, userOptions = {}) {
|
|
@@ -1597,174 +1763,7 @@ if (document.getElementById("export-table") && typeof simpleDatatables.DataTable
|
|
|
1597
1763
|
})
|
|
1598
1764
|
})
|
|
1599
1765
|
}
|
|
1600
|
-
|
|
1601
|
-
<table id="export-table">
|
|
1602
|
-
<thead>
|
|
1603
|
-
<tr>
|
|
1604
|
-
<th>
|
|
1605
|
-
<span class="flex items-center">
|
|
1606
|
-
Name
|
|
1607
|
-
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1608
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1609
|
-
</svg>
|
|
1610
|
-
</span>
|
|
1611
|
-
</th>
|
|
1612
|
-
<th data-type="date" data-format="YYYY/DD/MM">
|
|
1613
|
-
<span class="flex items-center">
|
|
1614
|
-
Release Date
|
|
1615
|
-
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1616
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1617
|
-
</svg>
|
|
1618
|
-
</span>
|
|
1619
|
-
</th>
|
|
1620
|
-
<th>
|
|
1621
|
-
<span class="flex items-center">
|
|
1622
|
-
NPM Downloads
|
|
1623
|
-
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1624
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1625
|
-
</svg>
|
|
1626
|
-
</span>
|
|
1627
|
-
</th>
|
|
1628
|
-
<th>
|
|
1629
|
-
<span class="flex items-center">
|
|
1630
|
-
Growth
|
|
1631
|
-
<svg class="w-4 h-4 ms-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
1632
|
-
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8 15 4 4 4-4m0-6-4-4-4 4"/>
|
|
1633
|
-
</svg>
|
|
1634
|
-
</span>
|
|
1635
|
-
</th>
|
|
1636
|
-
</tr>
|
|
1637
|
-
</thead>
|
|
1638
|
-
<tbody>
|
|
1639
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1640
|
-
<td class="font-medium text-heading whitespace-nowrap">Flowbite</td>
|
|
1641
|
-
<td>2021/25/09</td>
|
|
1642
|
-
<td>269000</td>
|
|
1643
|
-
<td>49%</td>
|
|
1644
|
-
</tr>
|
|
1645
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1646
|
-
<td class="font-medium text-heading whitespace-nowrap">React</td>
|
|
1647
|
-
<td>2013/24/05</td>
|
|
1648
|
-
<td>4500000</td>
|
|
1649
|
-
<td>24%</td>
|
|
1650
|
-
</tr>
|
|
1651
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1652
|
-
<td class="font-medium text-heading whitespace-nowrap">Angular</td>
|
|
1653
|
-
<td>2010/20/09</td>
|
|
1654
|
-
<td>2800000</td>
|
|
1655
|
-
<td>17%</td>
|
|
1656
|
-
</tr>
|
|
1657
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1658
|
-
<td class="font-medium text-heading whitespace-nowrap">Vue</td>
|
|
1659
|
-
<td>2014/12/02</td>
|
|
1660
|
-
<td>3600000</td>
|
|
1661
|
-
<td>30%</td>
|
|
1662
|
-
</tr>
|
|
1663
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1664
|
-
<td class="font-medium text-heading whitespace-nowrap">Svelte</td>
|
|
1665
|
-
<td>2016/26/11</td>
|
|
1666
|
-
<td>1200000</td>
|
|
1667
|
-
<td>57%</td>
|
|
1668
|
-
</tr>
|
|
1669
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1670
|
-
<td class="font-medium text-heading whitespace-nowrap">Ember</td>
|
|
1671
|
-
<td>2011/08/12</td>
|
|
1672
|
-
<td>500000</td>
|
|
1673
|
-
<td>44%</td>
|
|
1674
|
-
</tr>
|
|
1675
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1676
|
-
<td class="font-medium text-heading whitespace-nowrap">Backbone</td>
|
|
1677
|
-
<td>2010/13/10</td>
|
|
1678
|
-
<td>300000</td>
|
|
1679
|
-
<td>9%</td>
|
|
1680
|
-
</tr>
|
|
1681
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1682
|
-
<td class="font-medium text-heading whitespace-nowrap">jQuery</td>
|
|
1683
|
-
<td>2006/28/01</td>
|
|
1684
|
-
<td>6000000</td>
|
|
1685
|
-
<td>5%</td>
|
|
1686
|
-
</tr>
|
|
1687
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1688
|
-
<td class="font-medium text-heading whitespace-nowrap">Bootstrap</td>
|
|
1689
|
-
<td>2011/19/08</td>
|
|
1690
|
-
<td>1800000</td>
|
|
1691
|
-
<td>12%</td>
|
|
1692
|
-
</tr>
|
|
1693
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1694
|
-
<td class="font-medium text-heading whitespace-nowrap">Foundation</td>
|
|
1695
|
-
<td>2011/23/09</td>
|
|
1696
|
-
<td>700000</td>
|
|
1697
|
-
<td>8%</td>
|
|
1698
|
-
</tr>
|
|
1699
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1700
|
-
<td class="font-medium text-heading whitespace-nowrap">Bulma</td>
|
|
1701
|
-
<td>2016/24/10</td>
|
|
1702
|
-
<td>500000</td>
|
|
1703
|
-
<td>7%</td>
|
|
1704
|
-
</tr>
|
|
1705
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1706
|
-
<td class="font-medium text-heading whitespace-nowrap">Next.js</td>
|
|
1707
|
-
<td>2016/25/10</td>
|
|
1708
|
-
<td>2300000</td>
|
|
1709
|
-
<td>45%</td>
|
|
1710
|
-
</tr>
|
|
1711
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1712
|
-
<td class="font-medium text-heading whitespace-nowrap">Nuxt.js</td>
|
|
1713
|
-
<td>2016/16/10</td>
|
|
1714
|
-
<td>900000</td>
|
|
1715
|
-
<td>50%</td>
|
|
1716
|
-
</tr>
|
|
1717
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1718
|
-
<td class="font-medium text-heading whitespace-nowrap">Meteor</td>
|
|
1719
|
-
<td>2012/17/01</td>
|
|
1720
|
-
<td>1000000</td>
|
|
1721
|
-
<td>10%</td>
|
|
1722
|
-
</tr>
|
|
1723
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1724
|
-
<td class="font-medium text-heading whitespace-nowrap">Aurelia</td>
|
|
1725
|
-
<td>2015/08/07</td>
|
|
1726
|
-
<td>200000</td>
|
|
1727
|
-
<td>20%</td>
|
|
1728
|
-
</tr>
|
|
1729
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1730
|
-
<td class="font-medium text-heading whitespace-nowrap">Inferno</td>
|
|
1731
|
-
<td>2016/27/09</td>
|
|
1732
|
-
<td>100000</td>
|
|
1733
|
-
<td>35%</td>
|
|
1734
|
-
</tr>
|
|
1735
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1736
|
-
<td class="font-medium text-heading whitespace-nowrap">Preact</td>
|
|
1737
|
-
<td>2015/16/08</td>
|
|
1738
|
-
<td>600000</td>
|
|
1739
|
-
<td>28%</td>
|
|
1740
|
-
</tr>
|
|
1741
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1742
|
-
<td class="font-medium text-heading whitespace-nowrap">Lit</td>
|
|
1743
|
-
<td>2018/28/05</td>
|
|
1744
|
-
<td>400000</td>
|
|
1745
|
-
<td>60%</td>
|
|
1746
|
-
</tr>
|
|
1747
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1748
|
-
<td class="font-medium text-heading whitespace-nowrap">Alpine.js</td>
|
|
1749
|
-
<td>2019/02/11</td>
|
|
1750
|
-
<td>300000</td>
|
|
1751
|
-
<td>70%</td>
|
|
1752
|
-
</tr>
|
|
1753
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1754
|
-
<td class="font-medium text-heading whitespace-nowrap">Stimulus</td>
|
|
1755
|
-
<td>2018/06/03</td>
|
|
1756
|
-
<td>150000</td>
|
|
1757
|
-
<td>25%</td>
|
|
1758
|
-
</tr>
|
|
1759
|
-
<tr class="hover:bg-neutral-secondary-soft cursor-pointer">
|
|
1760
|
-
<td class="font-medium text-heading whitespace-nowrap">Solid</td>
|
|
1761
|
-
<td>2021/05/07</td>
|
|
1762
|
-
<td>250000</td>
|
|
1763
|
-
<td>80%</td>
|
|
1764
|
-
</tr>
|
|
1765
|
-
</tbody>
|
|
1766
|
-
</table>
|
|
1767
|
-
{{< /example >}}
|
|
1766
|
+
```
|
|
1768
1767
|
|
|
1769
1768
|
## JavaScript behaviour
|
|
1770
1769
|
|
|
@@ -1772,20 +1771,20 @@ Learn more about how you can customize the DataTables plugin such as changing th
|
|
|
1772
1771
|
|
|
1773
1772
|
After installing the DataTables plugin either via NPM or CDN you can initialize by calling the `DataTable` constructor and passing the table selector as the first argument.
|
|
1774
1773
|
|
|
1775
|
-
|
|
1774
|
+
```javascript
|
|
1776
1775
|
// if you installed via CDN
|
|
1777
1776
|
const dataTable = new simpleDatatables.DataTable("#default-table");
|
|
1778
1777
|
|
|
1779
1778
|
// if you installed via NPM
|
|
1780
1779
|
import { DataTable } from "simple-datatables";
|
|
1781
1780
|
const dataTable = DataTable("#default-table");
|
|
1782
|
-
|
|
1781
|
+
```
|
|
1783
1782
|
|
|
1784
1783
|
You can pass an object of options as the second argument to customize the table appearance and behavior.
|
|
1785
1784
|
|
|
1786
|
-
|
|
1785
|
+
```javascript
|
|
1787
1786
|
const dataTable = new simpleDatatables.DataTable("#default-table", options);
|
|
1788
|
-
|
|
1787
|
+
```
|
|
1789
1788
|
|
|
1790
1789
|
After initializing the DataTable, you can access the instance methods and properties.
|
|
1791
1790
|
|
|
@@ -1799,7 +1798,7 @@ Check out some of the more commonly used options that you can pass to the DataTa
|
|
|
1799
1798
|
|
|
1800
1799
|
Use the `data` option to pass data from an array of arrays to the table using JavaScript.
|
|
1801
1800
|
|
|
1802
|
-
|
|
1801
|
+
```javascript
|
|
1803
1802
|
const customData = {
|
|
1804
1803
|
"headings": [
|
|
1805
1804
|
"Name",
|
|
@@ -1820,7 +1819,7 @@ const customData = {
|
|
|
1820
1819
|
};
|
|
1821
1820
|
|
|
1822
1821
|
const dataTable = new DataTable("#default-table", { data: customData });
|
|
1823
|
-
|
|
1822
|
+
```
|
|
1824
1823
|
|
|
1825
1824
|
This is a useful feature where instead of a hard coded array you can pass data from an API or a JSON file.
|
|
1826
1825
|
|
|
@@ -1828,7 +1827,7 @@ This is a useful feature where instead of a hard coded array you can pass data f
|
|
|
1828
1827
|
|
|
1829
1828
|
Use the following options to customize the appearance of the table such as adding a caption, custom classes, footer, header, updating the HTML rendering template, and enabling vertical scrolling, and more.
|
|
1830
1829
|
|
|
1831
|
-
|
|
1830
|
+
```javascript
|
|
1832
1831
|
const dataTable = new DataTable("#default-table", {
|
|
1833
1832
|
caption: "Flowbite is an open-source library",
|
|
1834
1833
|
classes: {
|
|
@@ -1845,7 +1844,7 @@ const dataTable = new DataTable("#default-table", {
|
|
|
1845
1844
|
},
|
|
1846
1845
|
scrollY: "300px", // enable vertical scrolling
|
|
1847
1846
|
});
|
|
1848
|
-
|
|
1847
|
+
```
|
|
1849
1848
|
|
|
1850
1849
|
These options are useful if you want to add your own HTML elements inside the dynamically generated table header or footer as we used in the export a file example above.
|
|
1851
1850
|
|
|
@@ -1853,7 +1852,7 @@ These options are useful if you want to add your own HTML elements inside the dy
|
|
|
1853
1852
|
|
|
1854
1853
|
Use these options to enable pagination, set the number of rows per page, and customize the appearance.
|
|
1855
1854
|
|
|
1856
|
-
|
|
1855
|
+
```javascript
|
|
1857
1856
|
const dataTable = new DataTable("#default-table", {
|
|
1858
1857
|
paging: true, // enable or disable pagination
|
|
1859
1858
|
perPage: 10, // set the number of rows per page
|
|
@@ -1861,7 +1860,7 @@ const dataTable = new DataTable("#default-table", {
|
|
|
1861
1860
|
firstLast: true, // enable or disable the first and last buttons
|
|
1862
1861
|
nextPrev: true, // enable or disable the next and previous buttons
|
|
1863
1862
|
});
|
|
1864
|
-
|
|
1863
|
+
```
|
|
1865
1864
|
|
|
1866
1865
|
Pagination is a useful feature when you have a large dataset and you want to split it into multiple pages.
|
|
1867
1866
|
|
|
@@ -1869,13 +1868,13 @@ Pagination is a useful feature when you have a large dataset and you want to spl
|
|
|
1869
1868
|
|
|
1870
1869
|
These options can be used to enable searching, set the search placeholder, and customize the appearance.
|
|
1871
1870
|
|
|
1872
|
-
|
|
1871
|
+
```javascript
|
|
1873
1872
|
const dataTable = new DataTable("#default-table", {
|
|
1874
1873
|
searchable: true, // enable or disable searching
|
|
1875
1874
|
sensitivity: "base" // set the search sensitivity (base, accent, case, variant)
|
|
1876
1875
|
searchQuerySeparator: " ", // set the search query separator
|
|
1877
1876
|
});
|
|
1878
|
-
|
|
1877
|
+
```
|
|
1879
1878
|
|
|
1880
1879
|
The searching feature is great when you have a large dataset and you want to search for a specific row.
|
|
1881
1880
|
|
|
@@ -1883,7 +1882,7 @@ The searching feature is great when you have a large dataset and you want to sea
|
|
|
1883
1882
|
|
|
1884
1883
|
Use these options to enable sorting, set the default sort column, and customize the sort appearance.
|
|
1885
1884
|
|
|
1886
|
-
|
|
1885
|
+
```javascript
|
|
1887
1886
|
const dataTable = new DataTable("#default-table", {
|
|
1888
1887
|
sortable: true, // enable or disable sorting
|
|
1889
1888
|
locale: "en-US", // set the locale for sorting
|
|
@@ -1891,7 +1890,7 @@ const dataTable = new DataTable("#default-table", {
|
|
|
1891
1890
|
caseFirst: "false", // set the case first for sorting (upper, lower)
|
|
1892
1891
|
ignorePunctuation: true // enable or disable punctuation sorting
|
|
1893
1892
|
});
|
|
1894
|
-
|
|
1893
|
+
```
|
|
1895
1894
|
|
|
1896
1895
|
The sorting feature is useful when you want to sort the table rows based on a specific column.
|
|
1897
1896
|
|
|
@@ -1899,7 +1898,7 @@ The sorting feature is useful when you want to sort the table rows based on a sp
|
|
|
1899
1898
|
|
|
1900
1899
|
Check out some of the common methods that you can use to interact with the DataTable instance.
|
|
1901
1900
|
|
|
1902
|
-
|
|
1901
|
+
```javascript
|
|
1903
1902
|
// programatically search the table where the "term" variable is the query string
|
|
1904
1903
|
dataTable.search(term, columns);
|
|
1905
1904
|
|
|
@@ -1913,7 +1912,7 @@ dataTable.insert({
|
|
|
1913
1912
|
|
|
1914
1913
|
// updates the DOM of the table
|
|
1915
1914
|
dataTable.update();
|
|
1916
|
-
|
|
1915
|
+
```
|
|
1917
1916
|
|
|
1918
1917
|
Here's a full list of the <a href="https://fiduswriter.github.io/simple-datatables/documentation/#methods" target="_blank" rel="nofollow">exposed methods and properties</a> from the simple-datatables repository.
|
|
1919
1918
|
|