jQuery DataTables Responsive & Column Searching
by Paul Zepernick
HTML
<link rel="stylesheet" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.0.0/css/responsive.dataTables.min.css">
<script src="https://cdn.rawgit.com/zepernick/DataTables-ColumnSearching/master/js/datatables.colsearch.plugin.js"></script>
<script src="https://cdn.rawgit.com/zepernick/Responsive/resize-event/js/dataTables.responsive.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<table id="example" class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
...
JavaScript
$(function() {
var dt = $("#example").DataTable({
responsive: true
});
new $.fn.dataTable.DtColSearch(dt, {
select : [
{
name: 1, // could also use "data" name here too
options: ["System Architect", "Accountant", "Junior Technical Author", "Senior Javascript Developer", "Integration Specialist"]
}
]
});
});