Entries Per Page + Pagination Bug

Entries Per Page + Pagination Bug

ubunTuxubunTux Posts: 7Questions: 0Answers: 0
edited October 2009 in Bug reports
Using the full_numbers pagination type, and override the length menu...
[code]
'oLanguage': {
'sLengthMenu': 'Show '+
'20'+
'50'+
'All'+
' entries'
}
[/code]

Whenever I select "All", the FIRST and PREVIOUS links are disabled but the NEXT and LAST are still enabled. All of them should be disabled if "All" is selected from the drop down.

How can I fix this?

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi ubunTux,

    That's a bug in the current release of DataTables. Thanks for finding and reporting it! The fix is fairly simple. Line 510:

    [code]
    // replace: if ( iCurrentPage == iPages )
    // with:
    if ( iCurrentPage == iPages || oSettings._iDisplayLength == -1 )
    [/code]
    This will be included in the next release of DataTables.

    Regards,
    Allan
  • ubunTuxubunTux Posts: 7Questions: 0Answers: 0
    Hello Allan,

    Thanks for the fix. I applied it and it indeed disabled the "Next" and "Last" buttons. But only visually coz if you try to click on it several times, something wrong will happen. I am not good with JavaScript, which is the main reason I can't debug and apply patches for it. Pardon me if all I can do is report bugs I find.

    One more thing I'd like to verify, Sorting should come with Pagination right? What I mean is, if I'm viewing 20 records per page and sorted it via a specified column, it should sort only the current 20 records on that page. But what happens is, it sorts out the entire records (which is logically correct if we're viewing all records). Correct me if I am wrong about this, it's just an opinion anyway.

    Again, thanks for the fix you told me. Hope you could also show me the way to fix the related bug I discovered.



    Regards,
    ubunTux
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi ubanTux,

    Good call again :-) - thanks for testing this feature out and reporting back what you are finding! Indeed you are right again, there is a bug in the click event handlers. If you replace the click event handlers in fnInit for the full_numbers paging it should work a treat for you:

    [code]
    $(nFirst).click( function () {
    oSettings._iDisplayStart = 0;
    fnCallbackDraw( oSettings );
    } );

    $(nPrevious).click( function() {
    oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ?
    oSettings._iDisplayStart - oSettings._iDisplayLength :
    0;

    /* Correct for underrun */
    if ( oSettings._iDisplayStart < 0 )
    {
    oSettings._iDisplayStart = 0;
    }

    fnCallbackDraw( oSettings );
    } );

    $(nNext).click( function() {
    if ( oSettings._iDisplayLength >= 0 )
    {
    /* Make sure we are not over running the display array */
    if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
    {
    oSettings._iDisplayStart += oSettings._iDisplayLength;
    }
    }
    else
    {
    oSettings._iDisplayStart = 0;
    }

    fnCallbackDraw( oSettings );
    } );

    $(nLast).click( function() {
    if ( oSettings._iDisplayLength >= 0 )
    {
    var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
    oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
    }
    else
    {
    oSettings._iDisplayStart = 0;
    }

    fnCallbackDraw( oSettings );
    } );
    [/code]
    Regards,
    Allan
  • ubunTuxubunTux Posts: 7Questions: 0Answers: 0
    edited October 2009
    Whoa! Thanks again Allan! The fix made it even greater! Kudos!


    .ubunTux
This discussion has been closed.