Possible bug: Datatables row striping changes when scrolling towards bottom of table
Possible bug: Datatables row striping changes when scrolling towards bottom of table
I think I'm encountering issue #48 (https://github.com/DataTables/Scroller/issues/48) on Scroller 2.0.1.
I've made an example reproducing it here: http://live.datatables.net/tiwuqomo/45/edit
Scroll to the bottom; as you near the bottom, you'll suddenly see the row striping jump unexpectedly between rows. If you scroll back up, it suddenly jumps back. If you check the console output, you'll see it notes when the row striping is messing up, along with the requested start/end indeces.
Here's why I think this happens:
For a table of say, 99 records, with a viewable range of, say, 20 rows, and Scroller's parameters set to:
scroller: {
boundaryScale: 0.3,
displayBuffer: 3,
},
This should mean that Scroller is trying to fetch 60 rows' worth of data on each Ajax request (3x the 20 visible rows)
Set up like this, each time I scroll down, Scroller would choose another start position (I note they were always even numbers) and request 60 more records from there.
Everything is fine with the row striping until I scroll to the end of the table. As I get too close, the requests seemed to switch to the last 60 records in the dataset. I.e. from 99 back to.. 39. An odd number!
As soon as this happens, the row striping jumps position. If I scroll back up (and thus Scroller soon requests, say, rows 38 to 98, or 30 to 90) the row striping jumps back again, and remains in place all the way to the top of the table.
It seems that either of the following cases, when scrolling to the bottom of the table, can cause Scroller to request an odd start index and thus row striping to jump:
A table with an even number of total records, but an odd number of viewable rows (i.e. 100 records, 19 visible at any time).
A table with an odd number of total records, but an even number of viewable rows (ie. 99 records, 20 visible at any time)
tl;dr: In either of the above cases, once Scroller tries to fetch the "last X" records of the dataset, it winds up with an odd start row and the striping jumps position until you scroll back up and a subsequent request can pick an even index again.
Answers
Hi @NbrTDB ,
Thanks for the detailed explanation, and the test case - I agree, something looks wonky there. I've raised it internally (DD-1233 for my reference) and we'll report back here when there's an update.
Cheers,
Colin
Hi Colin, sorry, I forgot to reply to this one... thanks for taking a look and logging it as an issue!
I see since then that Scroller 2.0.2 is out, just to confirm it does seem like the issue persists on that version (actually, on my application, Scroller 2.0.2 breaks DataTables in other ways it seems... it's as if the displayBuffer now appears to be interpreted as # of rows as opposed to # of full table's worth of content to buffer, so with a displayBuffer of 3, I get 3 rows on the screen... I suppose that's an issue for another thread though!).
Anyway, thanks again for taking a look.
Hi there, just wondering if there has been any movement on this in the internal tracker (DD-1233, I suppose?). I've had a crack at Scroller 2.0.2. and 2.0.3 using the above example but the behaviour seems to be the same.
I'm sorry, I haven't had a chance to look into this over other things yet. I'll update this thread when I do, although I'm not yet sure when that will be.
Allan
OK no problem Allan, thanks for letting me know, I appreciate it!