0
votes

I have a DataTable (1.10.0) running with the help of CodeIgniter. The data is provided by ajax with Datatables library. Everything is running fine.

I would like to insert an input field somewhere on my page to filter/search only one column. I have tried with:

$('#customer').on( 'keyup click', function () {
  $('#results').DataTable().search(
    $('#customer').val()
  ).draw();
} );

This searches in all columns, and changes the value in the DataTables' own search field. If I add column(), it will not search in the table anymore, although it draws all ajax data again without filter/search.

$('#customer').on( 'keyup click', function () {
  $('#results').DataTable().column(0).search(
    $('#customer').val()
  ).draw();
} );

My question: What is the proper way to implement external column search/filter on server-side processed data?

Thanks!

1

1 Answers

0
votes

You are using column().search() API function correctly.

However with server-side processing, individual column searches are sent in separate request parameters, see Server-side processing.

For example, if you search the first column with value John Doe, your server side script will receive a request with parameter columns[0][search][value] set to John Doe while global search parameter search[value] would be empty.

You need to handle this individual column searches separately on the server-side, either manually or with help of a library.