Skip to content

Search Capability

Paprika69 edited this page Nov 27, 2017 · 7 revisions

how we search

In our books, authors and publishers pages, we used DataTables to show the data from our database. By calling the Search API provided by DataTables, we implemented the global search function for each table. Details are showing below:

Local Installation

We imported the JavaScript source by adding <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> in

section.

HTML Configuration

We used <table id="table" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%"> to customise our table and added each header and row by using <thead> and <tr>.

Calling the Search API

To implement the search function, we called the global search API by using

<script>
      $(document).ready(function() {
        $('#table').DataTable({
          "order": [[ 0, "asc" ]],
          "iDisplayLength": 50
        });
      });
 </script>
```
This JavaScript also made our table sortable and can change entries that are shown each page. 

Clone this wiki locally