0

I'm new in using JQuery DataTables. My problem is the following:

I have 157 entries in my Table. I set PageLength to 10 and paging to true. When loading the page, Datatables show me the first 10 entries but when i go to page 2, Datatables show me all entries in the Table except the rows from page 1.

On my other page I use the same code and everything works perfectly.

Datatables is loaded like this:

var table = $('#myArchiveTable').DataTable({
            order: [[1, 'desc']],
            paging: true,
            pageLength: '10',

            ...

Please help me!

Thanks

SR22
  • 3
  • 1
  • 1
  • 5

2 Answers2

2

The problem is with:

pageLength: '10'

It should be:

pageLength: 10

in order to be treated as a number.

jsfiddle based on Mayank Pandeyz's answer.

tgogos
  • 23,218
  • 20
  • 96
  • 128
  • 1
    Thank you for providing the additional details. I converted pageLength value to integer using JavaScript function parseInt() and it worked. – lexjwa Dec 31 '20 at 12:32
1

Remove the pageLength: '10' from the datatable properties and try again.

Ex:

$(document).ready(function() {
    $('#example').DataTable( {
        paging: true,
        //pageLength: '10',
    });
});

To change the default length, try:

"lengthMenu": [[25, 50, -1], [25, 50, "All"]]

Working Fiddle Example

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59