Pagination problems when using column filter and iDisplayLength

Pagination problems when using column filter and iDisplayLength

PeteBPeteB Posts: 38Questions: 0Answers: 0
edited March 2012 in General
I've made some progress with my table and implemented multi-column filtering which seems to be fine - but my paging seems to have been thrown out of kilter when I add an "iDisplayLength" parameter to the initialisation

I have uploaded my table to the debugger (code: awifum) and can provided other docs if necessary.

Everything seems o.k. without the "iDisplayLength" but when it is included:

a) 'first' and 'last' buttons seem to work ok.
b) when using the full_numbers option if I click '2' for page two the length of display goes from the next row to the end of the data (i.e. instead of "showing 21 to 40 of 1692" it is "showing 21 to 1692 of 1692")
c) similarly, if I am on the last page and click "prev" the start row is reduced by 20 (my page length) but the display shows from there to the end of the table.
d) the 'prev' button gets an error from line 1325 of jquery.dataTables.js that aoData is is undefined: [code] if ( oSettings.aiDisplay.length !== 0 )
{
var iStart = oSettings._iDisplayStart;
var iEnd = oSettings._iDisplayEnd;
if ( oSettings.oFeatures.bServerSide )
{
iStart = 0;
iEnd = oSettings.aoData.length;
}
for ( var j=iStart ; j

Replies

  • KussieKussie Posts: 6Questions: 0Answers: 0
    I'm having a similar issue using infinite scroll.

    The first lot of data shows correctly and the page position shows:
    Showing 1 to 25 of 107 entries

    Then when scrolling down to trigger the next page, i get the next lot of data as i would expect (So the data is correct)
    But it shows the following:
    Showing 1 to 107 of 107 entries

    And won't load anymore so all the next entries are not being displayed.

    If i remove the "'iDisplayLength' => '25'," setting it works fine. But setting that manually causes it to break.

    In addition another issue occurs when using infinite scrolling with a table set to bigger then the first result set.

    Say setting sScrollY to 400px and then when having rows that take up less space (Like say ten) then that sScrollY will cause the scroll bar not to show up, thus meaning you can't scroll and cause the additional rows of data to show up.
  • KussieKussie Posts: 6Questions: 0Answers: 0
    As i discovered make sure the value of iDisplayLength doesn't have quotes around it.

    I was getting a similar issue when using the following:
    'iDisplayLength' => '25',

    I changed it to this and had no more issues and everything worked correctly:
    'iDisplayLength' => 25,
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    @Pete: From your init in the debug trace (thanks for that) I think Kussie has hit on the issue you are facing. You are giving iDisplayLength as a string, not a number - DataTables is expecting a number, so giving it a string causes it to get confused.

    Allan
  • PeteBPeteB Posts: 38Questions: 0Answers: 0
    Allan/Kussie,

    yes, that was exactly it. I removed the quotes and everything flew perfectly.

    p.s. It also removed the need for my next call which was going to be "Why does the info show as 'records 1 to 020 of 1,922'"? (i.e. have a leading zero!)

    Thanks again to you both,
    Pete.
This discussion has been closed.