8

I'm trying to work with the pagination of the jquery datatables. I load the data with ajax. My response is now:

aaData: [[:anonymous:, null, 2012-07-29 08:28:21, 0, 85 million, null],…]
iTotalDisplayRecords: 70
iTotalRecords: 70
sEcho: 1

All of my records (70) are shown, how can I make them paginate and have for ex 10 records per page?

I tried settings iTotalDisplayRecords to 10 but it shows the same result.

My datatable init:

myDataTable = $('#datatablesresults').dataTable({
    bProcessing  : true,
    sProcessing  : true,
    bServerSide  : true,
    sAjaxSource  : '/results/load-results?' + getParams,
    aoColumnDefs : [{'bSortable' : false, 'aTargets' : ['no-sort']}], // make the actions column unsortable
    sPaginationType : 'full_numbers',
    fnDrawCallback  : function(oSettings) {
        _initTable();
    }
});
1
  • 1
    Did you find any reason or solution to this problem.I am stuck up with same problem Commented Dec 30, 2015 at 15:15

3 Answers 3

16

try this:

$("#myDataTable").dataTables({
     "bJQueryUI":true,
      "bSort":false,
      "bPaginate":true,
      "sPaginationType":"full_numbers",
       "iDisplayLength": 10
});
Sign up to request clarification or add additional context in comments.

1 Comment

I have the correct number of pages and I can slide through them, but I still get all my records on every tab. Like this: Showing 21 to 30 of 70 entries, but he shows all 70
3
$('#example').dataTable( {
  "pagingType": "full_numbers"
} );


DataTables has six built-in paging button arrangements:

numbers - Page number buttons only (1.10.8)
simple - 'Previous' and 'Next' buttons only
simple_numbers - 'Previous' and 'Next' buttons, plus page numbers
full - 'First', 'Previous', 'Next' and 'Last' buttons
full_numbers - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
first_last_numbers - 'First' and 'Last' buttons, plus page numbers

1 Comment

Note that as of v2.1 this feature has been deprecated, see datatables.net/reference/option/pagingType
0

For anyone looking simply how to change number of pages displayed in pagination here is code snippet.

jQuery.fn.dataTableExt.pager.numbers_length = 10;

$(document).ready(function() {
  // Basic datatable
  $('#datatable').DataTable();
  .... rest of the code below....

You can change number of pages displayed in pagination changing the value '10' in first line.

1 Comment

Exactly was searching for this info, thank you very much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.