How to create a global search filter for certain column?

How to create a global search filter for certain column?

nickelaosnickelaos Posts: 2Questions: 2Answers: 0
edited August 2016 in Free community support

I have 5 separate tables on my page with the same columns structure. In this page I need to create a search box that would perform search query in all given tables but in the same column. I used reg. exp. Search API functions which are described here: https://datatables.net/examples/api/regex.html This is my jquery code:

function filterColumn ( i ) {
    $('.table').DataTable().column( i ).search(
        $('#col'+i+'_filter').val(),
        $('#col'+i+'_regex').prop('checked'),
        $('#col'+i+'_smart').prop('checked')
    ).draw();
}
 
$(document).ready(function() {
    $('.table').DataTable({
        
    });
 
    $('input.column_filter').on( 'keyup click', function () {
        filterColumn( $(this).parents('tr').attr('data-column') );
    } );
} );

This code works fine and it really performs the search query in columns but only in the 1st table. But I want it to make the same search query in all my 5 tables. What should I change in this code? Please, help.

This discussion has been closed.