Pagination not working when using post

Pagination not working when using post

raphdevraphdev Posts: 4Questions: 1Answers: 0

Hello

I use datatable since a long time for a internal website. Due to proxy I had to change a request from get to post and impossible to have pagination working. It is working well when using type: "GET"

I need to use service side processing because the table has more than 80000 values

This is the code:

    var table = $('#inventory').DataTable( {
      "language": { "infoFiltered": "" },
     // "ajax": "server_processing.php?c=VMINVENTORY&t=<?php echo strtotime(date_format($dateLastInventory , 'F j, Y, g:i a')); ?>",
           "ajax": {
                    url:"server_processing.php?c=VMINVENTORY&t=<?php echo strtotime($check->getSelectedDate()); ?>",
                    type:"POST"
                     },
      "deferRender": true,
       "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
      "search": {
        "smart": false,
        "regex": true
      },
       "dom": 'Blfrtip',
       "buttons": [
            'copy',
            'excel',
            'csv',
            'print'       
        ],
      "columnDefs": [
      { "targets": [ 0,  6, 7, 8, 9, 10, 11, 12,13, 15, 16, 17, 19,18,20,21,22,23,24,25,26], "visible": false } ,
      { "searchable": false, "targets": [ 21,22 ] }
      ],
        "processing": true,
      "fixedHeader": true,
      "serverSide": true,                                      

} );

Is there a know bug in datatables?

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,152Questions: 27Answers: 367

    impossible to have pagination working.

    What does that mean? What happens? What are you seeing?

  • kthorngrenkthorngren Posts: 14,649Questions: 25Answers: 3,478

    Make sure your server script is setup up to process POST parameters instead of GET.

    Kevin

  • raphdevraphdev Posts: 4Questions: 1Answers: 0

    Im seeing all the output in one page, 80000 lines

  • raphdevraphdev Posts: 4Questions: 1Answers: 0

    "Make sure your server script is setup up to process POST parameters instead of GET."

    How to do that?

  • kthorngrenkthorngren Posts: 14,649Questions: 25Answers: 3,478
    edited December 2021 Answer ✓

    That depends on what you are using for your server script. If you are using the PHP SSP script provided by Datatables then see this example. Click the Server-side script tab.

    What are you using for your server side script?

    Kevin

  • raphdevraphdev Posts: 4Questions: 1Answers: 0

    Hello Kevin

    Thanks, with your help i have replaced
    echo json_encode( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraCondition) );

    to

    echo json_encode( SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraCondition) );

    And it works :)

Sign In or Register to comment.