sanduni jayawardena sanduni jayawardena - 1 year ago 60
Ajax Question

How to add auto complete to a table in php

I need to add autocomplete function to a table when searchg by entering a keyword in a textbox. i have less expirience in php laravel.
My requirement is as below. In the interface there is a text box to search and a table is displaying below that.

For an example it's process is like if i enter "a" in the text box, all the records which starting from "a" should display in the table and the displaing outputs in table should change acording to the entering input. If the search textbox is empty all the records should display in the table.

Answer Source

There are two ways of solving this with DataTables.

  1. The whole table data is sent to client side on page load.
  2. The whole data is too big to be sent over to client in one page reload and you need to do this in chunks/pagination.

In case of 1st possibility, this is as simple as including the js,css files and then instantiating the dataTable after the dom has loaded, this will replace the static HTML table with a dynamic searchable table, no additional changes are needed on server end.

In case of 2nd possibility, you are going to need to use to implement dataTable with ajax pagination. But this requires a controller(since you are working with laravel) to output the data in json format for the datatables to process.

A live example of case 1, case 2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download