John Smith
John Smith

Reputation: 6207

Bootstrap, datatable, AJAX, search

I understand that there is AJAX: https://datatables.net/examples/data_sources/server_side.html and there is searching: https://datatables.net/examples/api/multi_filter.html

but I have no idea how to combine the two. Exactly, when .search, which column does it search by? And what if I want to connect the conditions with ADD ?

Upvotes: 0

Views: 314

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58900

In server-side processing mode, jQuery DataTables sends the following parameters among many others:

search[value] Global search value. To be applied to all columns which have searchable as true.

columns[i][search][value] Search value to apply to this specific column.

So in the request there would be global search value and search value for each individual column ( columns[0][search][value], columns[1][search][value], etc.).

You would need to construct your database query to handle both parameters and return result in the appropriate format.

If you're using PHP, there is ssp.class.php that does it for you. Otherwise you may want to search for a library for your language of choice or write your own from scratch.

See server-side processing for more information.

Upvotes: 0

Related Questions