DataTables/DataTables — pull request #236 by khirakawa (2013-10-29 16:00:46+00:00)
Title: Accept iDisplayStart as part of _fnAjaxUpdateDraw's json parameter

I believe DataTables should accept iDisplayStart as a parameter to _fnAjaxUpdateDraw so that developers in the case the DT becomes out of sync with the backend.

Take the following scenario:

DataTables 1.9.4 with Scroller 1.1.0.
1) User A scrolls down to the bottom of the table where iDisplayStart is now, say, 120.
2) User B decides to delete every row except for a couple. The backend is now empty except for 2 items.
3) User A reloads the page. At this point, user A sees the last couple items render at position 120. Interestingly, DT will correct itself less than a second later. This makes the items effectively "jump" from the bottom to the top of the table.

This is essentially the problem we are hitting in our application. We believe this happens because DataTables and the backend are out of sync in terms of the start index. At step 3, DT requests items from 120, yet the backend returns with 2 items that start at index 0.

Our solution was to simply allow our API to return the correct start index, and let DT know about it by passing the start index as part of the json parameter passed to fnServerData's callback (along with iTotalRecords, iTotalDisplayRecords, etc). I am not sure how DT can otherwise figure out the correct start index.

Thanks!

(I know we had a thread going on via email, but I figured I'd just create the pull-request so we can track it here. Hope you didn't mind =) )