Reputation: 3899
I have simple table , and inside table i have some data to testing the DataTable. I set false to bFilter to hide the original search DataTable , and make my own.
The problem is , my own input Text not filtering data in table. Reference to this, I already to create like this in Jquery.
jQuery(document).ready(function ($) {
var table = $("#data-table").DataTable({
bSort: true,
bFilter: false,
iDisplayStart: 0,
iDisplayLength: 20,
sPaginationType: "full_numbers",
sDom: "Rfrtlip",
});
$("#searchFilter").keyup(function () {
table.search($(this).val()).draw();
});
});
But input Text won't filtering , i missed somewhere ?
<input type=\"text\" id=\"searchFilter\" name=\"searchFilter\" placeholder=\"Search...\" style=\"width:200px;\"/>
<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"stdtable \" id=\"data-table\">
<thead>
<tr>
<th>NO</th>
<th>JUDUL</th>
<th>TANGGAL</th>
<th>RINGKASAN</th>
<th>STATUS</th>
<th>KONTROL</th>
</tr>
</thead>
<tbody>
<tr>
<td>zazaza</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
</tr>
<tr>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
</tr>
<tr>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
</tr>
</tbody>
</table>
Upvotes: 0
Views: 2654
Reputation: 2147
Your search isn't working because you set the option bFilter: false
. You find more informations about bFilter here and about search() here.
I can show you a working example here:
$(document).ready(function() {
var table = $("#data-table").DataTable({
bSort: true,
// bFilter: false,
iDisplayStart: 0,
iDisplayLength: 20,
sPaginationType: "full_numbers",
sDom: "Rfrtlip",
});
$('#searchFilter').on('keyup', function() {
table.search(this.value).draw();
});
});
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<input type="text" id="searchFilter" name="searchFilter" placeholder="Search..." style="width:200px;" />
<table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="data-table">
<thead>
<tr>
<th>NO</th>
<th>JUDUL</th>
<th>TANGGAL</th>
<th>RINGKASAN</th>
<th>STATUS</th>
<th>KONTROL</th>
</tr>
</thead>
<tbody>
<tr>
<td>zazaza</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
</tr>
<tr>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
<td>asdsada</td>
</tr>
<tr>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
<td>remoremoreo</td>
</tr>
</tbody>
</table>
Upvotes: 1