Scroll a row or page into view?

Scroll a row or page into view?

swoyanswoyan Posts: 3Questions: 0Answers: 0
edited September 2009 in General
Hello.
I was looking for a way to force a particular row or page to be scrolled into view?
The particular issue is lets say they are on page 5 out of 10 and they are doing something to the data in another box/tab/whatever.
When they save those changes it has the the table redraw itself to reflect the new changes (the table is being populated via the server side pagination approach and no page reloading has occurred in this chain of events).

The draw function puts the table on page 1.
I know it's not exact science since the data is server side and they could have added or removed several rows, but a ball park "start on row 37 or start on page 5" type of thing would be more than sufficient.

I've tried the state saving feature but that doesn't work due to the draw function putting it back on page 1.

Any suggestions would be appreciated.

Thanks!

Replies

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin
    Hi swoyan,

    As long as you know the row element (i.e. the TR node) that is being updated, you can make use of the fnDisplayRow () plug-in API function: http://datatables.net/plug-ins/api#fnDisplayRow . Just pass the node you want to display to that function, and it will automatically jump the paging to the required page.

    Regards,
    Allan
  • swoyanswoyan Posts: 3Questions: 0Answers: 0
    Not quite because the table is actually redrawn and thus has all new nodes at that point.
    Plus since there are multiple users there could be a different amount of rows now.
    That's the main reason I don't just update the data in the table but rather let it redraw/refetch from the server.
    I was looking more of an initialization thing I would guess (such as start on page 20).
    That doesn't get the user exactly back to where they were but it's close enough.

    However that plugin code shows how to properly set the display start, so I can use that to accomplish it.
    I was just hesitant to start fooling around with manually setting the starting display number :)

    Thanks for your help!
  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin
    Hi swoyan,

    Ah I see - so you are re-initialising the table are you? You can use the 'iDisplayStart' initialisation parameter to tell DataTables to start displaying the data then - which I've just found out isn't documented... I'll add it in :-)

    Regards,
    Allan
This discussion has been closed.