show last row of infinite scroll using server side processing

show last row of infinite scroll using server side processing

migkemigke Posts: 6Questions: 0Answers: 0
edited November 2010 in General
Hello, first of all thanks for this fantastic plugin. I have a problem that i can't seem to solve it. I'm using datatables with infinite scroll and server side processing, the problem is that every time i initialize the table or do a fnDraw (to reload the database data) i would like to show to the user the last row (last data) of the table. Is there a way of setting the display using a value received from the database, like iTotalRecords -1 ? Thanks in advance!

Replies

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    I'm not quite clear on what you mean - sorry. Do you want to load all records and then scroll to the last one automatically? If so, you can just use scrollTo() on the scrolling element once the table has drawn.

    Allan
  • migkemigke Posts: 6Questions: 0Answers: 0
    First, thanks for the response. Yes, that's what i want to do, but does that plugin work with sever-side processing and infinite scroll? To what element of the Datatables object do i apply it to? I have tried to apply it directly to the table element ( $(#myTable).scrollTo() ) but it just moved it inside the div. Thanks.

    Mike
  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    If you are loading the entire table's data, infinite scroll doesn't really come into it does it? You've loaded the whole data set, so what would infinite scrolling actually do? That's the point I'm confused about. If you load the entire data set (which will likely need a small modification on the server-side to deal with a display length of -1), then you can match on the 'div.dataTables_scrollBody' element.

    Allan
  • migkemigke Posts: 6Questions: 0Answers: 0
    Ups, i forgot to mention that i am also using pagination, i am not loading the whole data set
  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    I'm afraid I still don't really understand - with infinite scrolling, DataTables uses the built in pagination to know when to load data or not. When you get to the bottom of what is currently being displayed, then it loads the next 'page' at the end of the scroller - you can then scroll down until you get to the end.

    Allan
  • migkemigke Posts: 6Questions: 0Answers: 0
    Yes!, you understood the problem correctly (it wasn't a problem after all) and now, with scrollTo, it works like a charm. Thank you for all the help!
This discussion has been closed.