Server side and SSP:complex

Server side and SSP:complex

caro.simcaro.sim Posts: 7Questions: 2Answers: 1
edited August 2016 in Free community support

Hello

I have a page with a request diplayed in Datatables with serverside option. I would like use where with complex method.

If I use the complex method with serverside = true, I have an error

DataTables warning: table id=ora_instance - Ajax error. For more information about this error, please see http://datatables.net/tn/7

The page displays fine but when I do a search in input, i have this error.

If I use the complex method with serverside = false, it works

This is a part of my code :

$(document).ready(function() {
var table = $('#test').DataTable( {
"processing": true,
"serverSide": true,
"deferRender": true,
"ajax": "test_req.php",
"dom": 'lBfrtip',
"buttons": [
{
extend: 'collection',
text: 'Exporter les données ',

            buttons: [
                'copy',
                'excel',
                'csv',
                'pdf',
                'print'
            ]
        }            
    ] 
} );    

// Setup - add a text input to each footer cell
$('#ora_instance tfoot th').each( function () {
    var title = $(this).text();
    $(this).html( '<input type="text" placeholder="'+title+'" />' );
} );


// Apply the search
table.columns().every( function () {
    var that = this;

    $( 'input', this.footer() ).on( 'keyup change', function () {
        if ( that.search() !== this.value ) {
            that
                .search( this.value )
                .draw();
        }
    } );
} );

} );


$where = "status='test'";
echo json_encode(
SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns, null, $where )
);

Thank you

This question has an accepted answers - jump to answer

Answers

  • caro.simcaro.sim Posts: 7Questions: 2Answers: 1
    edited August 2016

    For information, I use ssp.class.php that I updated for postgresql

    ssp.class.pgsql.php

    Maybe it is my probleme?

    Thank you for help

  • caro.simcaro.sim Posts: 7Questions: 2Answers: 1
    Answer ✓

    It works!!!

    We have replace in the complex method to

        // Total data set length
        $resTotalLength = self::sql_exec( $db, $bindings,
            "SELECT COUNT({$primaryKey})
             FROM   $table ".
            $whereAllSql
        );
        $recordsTotal = $resTotalLength[0][0];
    

    by

        // Total data set length
        $resTotalLength = self::sql_exec( $db, 
            "SELECT COUNT({$primaryKey})
             FROM   $table ".
            $whereAllSql
        );
        $recordsTotal = $resTotalLength[0][0];
    

    I posted on the github
    https://gist.github.com/carosim/42f7ba47f81c39c753bfd210772b9bdc

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Thanks for the updates - great to hear you've got it working now.

    Allan

This discussion has been closed.