Server Side Individual Column Filtering (Drop Down)

Server Side Individual Column Filtering (Drop Down)

Rogue1Rogue1 Posts: 3Questions: 2Answers: 0
edited March 2017 in Free community support

Hi, I am new to DataTables and I am trying to implement Column Filtering with drop down server side. The search drop down boxes get filled in correctly but when I select an option, I get "No entries found" Any help would be very appreciated. Here is my debug link: https://debug.datatables.net/ixicoh

Column Filtering with drop down (Want to use server side)

$(document).ready(function() {
    $('#example').DataTable(         
       "processing": true,
        "serverSide": true,
        "ajax": "server_processing.php",{
        initComplete: function () {
            this.api().columns().every( function () {
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
 
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                    } );
 
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        }
    } );
} );

Answers

  • Rogue1Rogue1 Posts: 3Questions: 2Answers: 0

    Solved: replaced

    column.search( val ? '^'+val+'$' : '', true, false ).draw();
    

    to

    column.search( this.value ).draw();
    
  • pjustindaryllpjustindaryll Posts: 13Questions: 4Answers: 0

    Rogue1, Thank you! this solved my problem as well.

This discussion has been closed.