Individual Column Search not working
Individual Column Search not working
pmuno007
Posts: 2Questions: 1Answers: 0
Hi everyone.
I am trying the code below. All the input boxes are added properly, but for some reason if I input anything on them, there is no filtering at all, nothing happens. Would appreciate if anyone would help me see what am I doing wrong.
Thanks.
Here is the code:
$(document).ready(function() {
// Setup
$('#outerTable thead th:gt(0)').each( function () {
var title = $('#outerTable thead th').eq( $(this).index() ).text();
$(this).append( '<br><input style="width:90px;" type="text" />' );
} );
// DataTable
var table = $('#outerTable').DataTable();
// Apply the search
table.columns( ':gt(0)' ).eq( 0 ).each( function ( colIdx ) {
var that = this;
$( 'input', this.header() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
} );
} );
} );
This discussion has been closed.
Answers
I think your issue revolves around the use of ':gt(0)'. Follow this example and it should work.
https://datatables.net/examples/api/multi_filter.html
Turns out I was using an older version of JQuery and this was causing the filtering issues. I updated it and it worked. The :gt(0) works fine. Thank you for the help!