Scroll to specific row with pagination

Scroll to specific row with pagination

emilemil Posts: 7Questions: 1Answers: 1

I have performance issues in IE using Scroller (deferRender: true, scroller: true) and would like to scroll exactly one row with each mousewheel scroll.

I'm using pagination and have set a function to scroll pages with the mousewheel. However this is too fast. Is there a way to move the table by one row at a time while iDisplayLength = 10? All I need right now is a way to place a specific row at the top of a page.

Something like:
myTable.row( rowNumber ).draw( false );

another option could be to:
hide offset number of rows
and call myTable.page( pageNumber ).draw( false );

for example if I want to scroll to row number 23 with iDisplayLength = 10, I would hide the first two rows and then set myTable.page( 2 ).draw( false );

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    The pagination control cannot be used with Scroller. The Scroller extension uses DataTables' paging to perform its own virtual calculations.

    Allan

  • emilemil Posts: 7Questions: 1Answers: 1
    edited February 2016

    I know that. I'm trying to find a way to display for example rows 23 - 32 with iDisplayLength = 10. Can you help me how I can identify the first N rows, that would be displayed on the first page based on the search filter?

    I'm thinking something like this:
    I create an ID column (hidden and preferably not searchable with my main filter) that contains a unique number for each row.
    Once search results are filtered I read the first N IDs from the current results (this is the part I don't know how to do).

    I add a filter to filter out the first N results from my current query. And display "scrolled data" to the user.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    For the same reason you can't use the paging controls with Scroller, you also can't set the page length. Scroller will do that for you based on the height of the rows, the height of the viewport and the display buffer option.

    Can you help me how I can identify the first N rows

    The nightly version of Scroller now has a scroller.page() method which will give you information about the visible rows in the viewport. It hasn't been released yet, but the documentation was committed here.

    Allan

  • emilemil Posts: 7Questions: 1Answers: 1

    I'll just use the current pagination, but I'll set iDisplayLength = 2N - 1.

    Then I'll hide a part of the div and move it based on the desired offset.

This discussion has been closed.