Individual Column Search with Server side Processing data is not filtering the results

Individual Column Search with Server side Processing data is not filtering the results

vkvaradhavkvaradha Posts: 7Questions: 2Answers: 0

Hi, I hope some one can help me to solve this issue. i need to use individual column filtering with server side processing. Here is my code.

 
    $('#example thead tr').each( function () {
        var title = $('#example thead tr').eq( $(this).index() ).text();
        $(this).html( '' );
    } );

    
    
    var table =  $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "../server_side/scripts/server_processing.php"
    } );
    
    
        table.columns().eq( 0 ).each( function ( colIdx ) {
        $( 'input', table.column( colIdx ).footer() ).on( 'keyup change', function () {
            table
                .column( colIdx )
                .search( this.value )
                .draw();
        } );
    } );

and my php code.

// DB table to use
$table = 'sales_orders';

// Table's primary key
$primaryKey = 'order_no';

// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
    array( 'db' => 'debtor_no', 'dt' => 0 ),
    array( 'db' => 'branch_code',  'dt' => 1 ),
    array( 'db' => 'deliver_to',   'dt' => 2 ),
    array( 'db' => 'order_type',     'dt' => 3 ),
    array(
        'db'        => 'ord_date',
        'dt'        => 4,
        'formatter' => function( $d, $row ) {
            return date( 'jS M y', strtotime($d));
        }
    ),
    array(
        'db'        => 'total',
        'dt'        => 5,
        'formatter' => function( $d, $row ) {
            return '$'.number_format($d);
        }
    )
);

// SQL server connection information
$sql_details = array(
    'user' => 'root',
    'pass' => '',
    'db'   => 'fa_revamp',
    'host' => 'localhost'
);


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * If you just want to use the basic configuration for DataTables with PHP
 * server-side, there is no need to edit below this line.
 */

require( 'ssp.class.php' );

echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);

Here the above code works by creating the datatable. but the problem is the individual filtering. When i try to write something inside the individual column filter textboxes, it shows an empty table, instead of the filtered results. "No matched Records Found" message will be appear here.

I know something i missed in my js. so help me to fix it. And the question may be existing. but my problem couldnt get solved without right help.

http://cdn.kvcodes.com/images/1.png

and

http://cdn.kvcodes.com/images/2.png

This discussion has been closed.