Individual column searching (text inputs) --> No matching records found
Individual column searching (text inputs) --> No matching records found
Hey,
I am new to DataTables and I have a problem with adding individual column searching via text inputs.
I found some similar posts about this topic but none met my needs.
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#results tfoot th').each( function () {
var title = $('#results thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
// DataTable
var table = $('#results').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
} );
} );
} );
Basically this is my code. My table has the id=results. The inputs are also initialized and shown.
But when I add some words, every time "No matching records found" is shown as a result of my search.
Why?
When i use global search, its working. But not as a column search...
EDIT: Code is from tutorial here https://datatables.net/examples/api/multi_filter.html
This question has accepted answers - jump to:
Answers
You have not copied the example correctly. A line is missing:
Oh, sorry. Thanks! How did that happen?
Nvm, it is still not working...
I found the problem: It didn't work because i have a column, that is not shown in the table and I didn't add the <th>-Tag in the foot.