Next putton in pagination is not taking user past page 2

Next putton in pagination is not taking user past page 2

tschrecktschreck Posts: 7Questions: 3Answers: 0

Hello. I've upgraded to DataTables-1.10.4. I noticed Next button for pagination for my AJAX tables was not working. My pagination is setup for 50 records per page. When I clicked the Next button on page 1, the 'Showing ...' message was changed to:

Showing 0,501 to 173 of 173 entries

Subsequent click of Next button would not do anything. All other buttons for pagination seem to work.

I tracked the issue to _fnPageChange method of jquery.dataTables.js (roughly line 3471). This is the original code:

    var
        start     = settings._iDisplayStart,
        len       = settings._iDisplayLength,
        records   = settings.fnRecordsDisplay();

I changed it to:

    var
        start     = parseInt(settings._iDisplayStart),
        len       = parseInt(settings._iDisplayLength),
        records   = settings.fnRecordsDisplay();

After adding parseInt() for start and len, the Next button pagination works.

Hopfully this will help someone else.

Thanks

Tom

Answers

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    Hi Tom,

    Thanks for your message. Are you able to modify your server return to return integers, rather than strings, are required int he server-side processing protocol?

    Allan

  • FlekyFleky Posts: 8Questions: 2Answers: 0

    Hello,

    i have the exactly same issue. I cannot declare integers because all params are transfered toJson.

    parseInt is safe solution to this problem. Unfortunately i don't like to touch to datatables lib.

    Tomas

  • tschrecktschreck Posts: 7Questions: 3Answers: 0

    hello. I have same issue as Tomas. I'm returning JSON, so everything is a string.

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    I'm returning JSON, so everything is a string.

    JSON can contains integers and floats as well. Are you not able to modify your JSON to return integers?

    Allan

  • tschrecktschreck Posts: 7Questions: 3Answers: 0

    it's my understanding that .Net returns JSON objects as strings and it's left up to client to convert accordingly.

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    I haven't had that problem while creating the Editor libraries for .NET. If an int is used then a Javascript number is given in the JSON.

    Allan

  • FlekyFleky Posts: 8Questions: 2Answers: 0
    edited June 2015

    Hi Allan,

    how can i modify my response in ajax call? it is ajax call by datatables itself so how to touch to response ?

  • FlekyFleky Posts: 8Questions: 2Answers: 0

    I found that form data contains param start: 0100 when clicking on next button second time. The question is why this param is badly set. I have pagination 100.

  • FlekyFleky Posts: 8Questions: 2Answers: 0

    I got it! I had a problem in setting of datatable.
    The param "pageLength" needs to be type INT and not string.

    "pageLength" : parseInt(localStorage.getItem('rowsPerPage'))

This discussion has been closed.