0

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

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 ? enter image description here

Table

 <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>

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.