My Pagination is not working. The Bootstrap works but the records are all dumped into one page.

My Pagination is not working. The Bootstrap works but the records are all dumped into one page.

ManxellionManxellion Posts: 3Questions: 1Answers: 0

My Datatable code:

$(".dataTable").dataTable({
             "bPaginate": true,
             "bLengthChange": false,
             "iDisplayLength" : 5,
             "sPaginationType": "simple_numbers",
             "bFilter" : false,
             "bServerSide": true,
             "sAjaxSource": source,
             "aoColumns": [{
                    "mData": "message",
                    "sTitle": "Message"
                  },{
                    "mData": "message_date",
                    "sTitle": "Message Date"
                  },{
                    "mData": "mobile",
                    "sTitle": "Mobile"
                  },{
                      "mData": "status_type",
                      "sTitle": "Status Type"
                  }],
            "aoColumnDefs" : [
                        { "aTargets": [ '_all' ], "bSortable": false } 
                             ]
         });

Here's the output:

alt text

As you can see, the bootstrap is working and it SHOULD BE showing 5 rows pero page.
BUT it's not. Help?

Answers

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    "bServerSide": true,

    Is the server only returning 5 rows? My guess is not - you need to look at whatever your source script is doing and address the issue there.

    Allan

  • ManxellionManxellion Posts: 3Questions: 1Answers: 0
    edited August 2015

    The server returns a variable amount of records depending on the number of records returned by the database. The "source" is just a variable that points to a link where the datatables script will get it's data from. AFAIK the iDisplayLength = 5 means that I'm forcing the datatables to only display 5 records per page.

    I may be confusing serverside and ajax-source types. I'll look into that.

  • ManxellionManxellion Posts: 3Questions: 1Answers: 0
    edited August 2015

    Derp, I fixed it. I mixed two types of sources. Apologies, am really new to datatables so the concept of Server-side processing confused me till I finally found the document I was looking for:

    http://legacy.datatables.net/examples/data_sources/server_side.html

    and compared it to this other document I found:

    http://legacy.datatables.net/examples/data_sources/ajax.html

    The entire time I was mixing both server-side and ajax when I aimed to do ajax type.

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    Good to hear you've got it working now.

    Allan

This discussion has been closed.