fnDisplayRow not working correctly with "All" selected in Display Length dropdown

fnDisplayRow not working correctly with "All" selected in Display Length dropdown

[Deleted User][Deleted User] Posts: 0Questions: 2Answers: 0
edited February 2012 in Bug reports
I have a filter applied to a table, with display length dropdown set to ALL (dropdown value = '-1').
When I call [code]myTable.fnDisplayRow(myTable.fnGetNodes(10))[/code] for example, it will show from row 10 to the end of the table. Rows 1 to 9 are not shown.

I have tracked the problem down to:
[code]
oSettings._iDisplayStart =
( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
[/code]

Obviously this calculation will not work when [code]oSettings._iDisplayLength[/code] is -1.

I tried putting wrapping the above line with [code]if(oSettings._iDisplayLength > 0)[/code] but the table jumps back to the top and does not jump to the row I want.

How do I fix this? Thanks

Replies

  • [Deleted User][Deleted User] Posts: 0Questions: 2Answers: 0
    bump.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    > it will show from row 10 to the end of the table. Rows 1 to 9 are not shown.

    What were you expecting the plug-in to do when you ask it to display row 10 when all rows are shown? I would suggest that perhaps the plug-in should just check for _iDisplayLength === -1 at the top of the function and if found to be as such, return and do nothing (since the row is already being shown).

    Allan
  • [Deleted User][Deleted User] Posts: 0Questions: 2Answers: 0
    If row 10 is onscreen, then it should do nothing.

    Good suggestion on the fix, I will try and update the thread soon :)
  • tomas_eklundtomas_eklund Posts: 14Questions: 1Answers: 0
    [quote]allan said: What were you expecting the plug-in to do when you ask it to display row 10 when all rows are shown? [/quote]

    I too would expect it to do nothing - not to mess up the display... ;-)

    I am using fnDisplayRow to make sure that a newly inserted row is shown on screen even when there is pagination going on (it doesn't handle filtering, but I might try and add that later).

    Right now the plug-in is obviously broken since it messes up the display by hiding all rows preceding the newly inserted one when _iDisplayLength is -1. I would kindly suggest that the "official" plug-in code be updated with the check that you suggest. I'm guessing that a lot of people will forget to test this case leading to a lot of broken and seemingly buggy DataTables implementations out there. It doesn't matter that the core is "rock solid" if the "official" plug-ins are broken.

    Adding this to the top of the function seemed to fix the problem, although if one extends the function to remove filtering (if necessary) to make sure the row is not hidden, a more sophisticated approach would be needed, of course.
    [code]if ( oSettings._iDisplayLength == -1 ) return;[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Agreed - I've added the line required to the plug-in :-)

    Looking at the plug-in I'm sure it could be optimised somewhat with the internal changes in 1.9 - I've made a note to look at doing that.

    Allan
This discussion has been closed.