ServerSide ignores paging

ServerSide ignores paging

classic12classic12 Posts: 228Questions: 60Answers: 4

I have this on the server

include( "DataTables.php" );


// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'customers' , 'custID')
    ->field(
        Field::inst( 'customers.custID' )->set(false),
        Field::inst( 'companyName' ),
        Field::inst( 'companyType' )
            ->options( Options::inst()
                ->table( 'companyTypes' )
                ->value( 'value' )
                ->label( 'label')
            ),
        Field::inst( 'address1' ),
        Field::inst( 'address2' ),
        Field::inst( 'address3' ),
        Field::inst( 'Town' ),
        Field::inst( 'Post_Code' ),
        Field::inst( 'Mobile' ),
        Field::inst( 'Telephone' ),
        Field::inst( 'Email' ),
        Field::inst( 'Notes' ),
        Field::inst( 'Member' )
        )
        ->join(
        Mjoin::inst( 'contacts' )
            ->link( 'customers.custID', 'contacts.custID' )
        ->fields(
        Field::inst( 'custID' )->set(false),    
        Field::inst( 'FirstName' ),
        Field::inst( 'Surname' ),
        Field::inst( 'Mobile' ),
        Field::inst( 'Email' )
            )
            
            )


    ->process( $_POST )
    ->json();
    
    

on the client I have

  $("#dtCustomers").dataTable().fnDestroy(); 
        $('#dtCustomers').empty();
        tableCustomers = $('#dtCustomers').DataTable( {

        ajax: "http://www.xxx.com/xxxx.php",
        serverSide : true,
        customerData : data,
        scrollY: "300px",
        scrollCollapse: true,
        paging: true,
        info: false,
        select: true,
        ordering: true,
        order: [[0, 'desc']],
        dom: "Bfrtip",
        autoWidth : true,
        responsive: true,
        select: true,

I'm testing to see if I get any quicker results.

If I set serverSide:false the paging works as expected but if I set to false the paging is ignored.

What am i missing here ?

Cheers

Steve Warby

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    You need to have DataTables make a POST request since you are using ->process( $_POST ). By default it will make a GET request.

    ajax: {
      url: "http://www.xxx.com/xxxx.php",
      type: 'POST'
    }
    

    Live example here.

    Allan

This discussion has been closed.