cdn

DataTables

Released Installed

jQuery-optional table plugin with sorting, searching, pagination, and a large extension ecosystem. This build is styled for Bootstrap 5.

Included in this bundle: DataTables 3.1.1, AutoFill, Buttons, ColReorder, ColumnControl, DateTime, FixedColumns, FixedHeader, KeyTable, Responsive, RowGroup, RowReorder, Scroller, SearchBuilder, Select


How to include

Load Bootstrap 5 CSS first, then DataTables CSS. Scripts: Bootstrap (for Buttons dropdowns) → DataTables. jQuery is optional in DataTables 3; use the vanilla new DataTable() API below.

<!-- CSS in <head>: Bootstrap + DataTables -->
<link rel="stylesheet" href="https://cdn.roste.org/bootstrap/latest/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.roste.org/datatables/latest/bs5/datatables.min.css" />

<!-- JS before </body>: Bootstrap → DataTables -->
<script src="https://cdn.roste.org/bootstrap/latest/bootstrap.bundle.min.js"></script>
<script src="https://cdn.roste.org/datatables/latest/bs5/datatables.min.js"></script>

<script>
  new DataTable('#myTable');
</script>

Download zip

Optional: jQuery API ($('#myTable').DataTable())
<script src="https://cdn.roste.org/jquery/latest/jquery.min.js"></script>
<script src="https://cdn.roste.org/bootstrap/latest/bootstrap.bundle.min.js"></script>
<script src="https://cdn.roste.org/datatables/latest/bs5/datatables.min.js"></script>
<script>$('#myTable').DataTable();</script>

Documentation & resources


Basic table

Default sorting, search, and pagination from a plain HTML <table>.

Name Position Office Age Start date Salary
Tiger NixonSystem ArchitectEdinburgh612011-04-25$320,800
Garrett WintersAccountantTokyo632011-07-25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009-01-12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012-03-29$433,060
Airi SatouAccountantTokyo332008-11-28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012-12-02$372,000
Herrod ChandlerSales AssistantSan Francisco592012-08-06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010-10-14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009-09-15$205,500
Sonya FrostSoftware EngineerEdinburgh232008-12-13$103,600
Jena GainesOffice ManagerLondon302008-12-19$90,560
Quinn FlynnSupport LeadEdinburgh222013-03-03$342,000

<table id="dt-basic" class="table table-striped" style="width:100%">
  <thead>
    <tr><th>Name</th><th>Position</th><th>Office</th><th>Age</th></tr>
  </thead>
  <tbody>
    <tr><td>Tiger Nixon</td><td>System Architect</td><td>Edinburgh</td><td>61</td></tr>
    <!-- more rows... -->
  </tbody>
</table>
<script>
  new DataTable('#dt-basic');
</script>

JavaScript data source

Initialize from an array of objects with columns.data.

<table id="dt-js" class="table table-striped" style="width:100%"></table>
<script>
new DataTable('#dt-js', {
  data: [
    { name: 'Tiger Nixon', position: 'System Architect', office: 'Edinburgh', salary: '$320,800' },
    { name: 'Garrett Winters', position: 'Accountant', office: 'Tokyo', salary: '$170,750' }
  ],
  columns: [
    { data: 'name', title: 'Name' },
    { data: 'position', title: 'Position' },
    { data: 'office', title: 'Office' },
    { data: 'salary', title: 'Salary' }
  ]
});
</script>

Responsive

Shrink the viewport (or widen columns) — child rows appear for hidden data. Resize the window to try it.

First name Last name Position Office Age Start date Salary Extn.
TigerNixonSystem ArchitectEdinburgh612011/04/25$320,8005421
GarrettWintersAccountantTokyo632011/07/25$170,7508422
AshtonCoxJunior Technical AuthorSan Francisco662009/01/12$86,0001562
CedricKellySenior Javascript DeveloperEdinburgh222012/03/29$433,0606224
AiriSatouAccountantTokyo332008/11/28$162,7005407

<table id="dt-responsive" class="table table-striped nowrap" style="width:100%">...</table>
<script>
  new DataTable('#dt-responsive', { responsive: true });
</script>

Buttons (copy / CSV / print)

Export and print via the Buttons extension. Layout places controls with the layout option (DataTables 2+).

NamePositionOfficeSalary
Tiger NixonSystem ArchitectEdinburgh$320,800
Garrett WintersAccountantTokyo$170,750
Ashton CoxJunior Technical AuthorSan Francisco$86,000
Cedric KellySenior Javascript DeveloperEdinburgh$433,060
Airi SatouAccountantTokyo$162,700

<table id="dt-buttons" class="table table-striped" style="width:100%">...</table>
<script>
new DataTable('#dt-buttons', {
  layout: {
    topStart: {
      buttons: ['copy', 'csv', 'print']
    }
  }
});
</script>

Row selection

Click rows to select (multi). Uses the Select extension.

NamePositionOfficeAge
Tiger NixonSystem ArchitectEdinburgh61
Garrett WintersAccountantTokyo63
Ashton CoxJunior Technical AuthorSan Francisco66
Cedric KellySenior Javascript DeveloperEdinburgh22
Airi SatouAccountantTokyo33

<table id="dt-select" class="table table-striped" style="width:100%">...</table>
<script>
  new DataTable('#dt-select', { select: true });
</script>

Row grouping

Group rows by a column with the RowGroup extension.

NamePositionOfficeSalary
Tiger NixonSystem ArchitectEdinburgh$320,800
Cedric KellySenior Javascript DeveloperEdinburgh$433,060
Sonya FrostSoftware EngineerEdinburgh$103,600
Quinn FlynnSupport LeadEdinburgh$342,000
Garrett WintersAccountantTokyo$170,750
Airi SatouAccountantTokyo$162,700
Rhona DavidsonIntegration SpecialistTokyo$327,900
Ashton CoxJunior Technical AuthorSan Francisco$86,000
Herrod ChandlerSales AssistantSan Francisco$137,500
Colleen HurstJavascript DeveloperSan Francisco$205,500

<table id="dt-rowgroup" class="table table-striped" style="width:100%">...</table>
<script>
new DataTable('#dt-rowgroup', {
  order: [[2, 'asc']],
  rowGroup: { dataSrc: 2 }
});
</script>