Infinite Scroll Height
Infinite Scroll Height
Hi! I am loving the new infinite scroll feature. I do have a question about it.
It seems that the height of the table (before you start scrolling) is determined by how many rows are in the table, overall. I am initializing the table with this code:
$(document).ready(function() {
$('#osw-edit-version-control').dataTable( {
"aaSorting": [ [1,'asc'], [2,'asc'] ],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "200px"
} );
} );
I thought that changing the sScrollY value would make my table taller (that is, show more rows before you have to start scrolling). However, changing it doesn't seem to have any effect that I can see. Right now, my table has a mere 7 rows, so I only see the first 4 (before scrolling). If I add more rows, then I see more (again, before scrolling). I was hoping to set the table height such that I would see at least 10 rows before scrolling. Is this doable?
Thanks!
It seems that the height of the table (before you start scrolling) is determined by how many rows are in the table, overall. I am initializing the table with this code:
$(document).ready(function() {
$('#osw-edit-version-control').dataTable( {
"aaSorting": [ [1,'asc'], [2,'asc'] ],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "200px"
} );
} );
I thought that changing the sScrollY value would make my table taller (that is, show more rows before you have to start scrolling). However, changing it doesn't seem to have any effect that I can see. Right now, my table has a mere 7 rows, so I only see the first 4 (before scrolling). If I add more rows, then I see more (again, before scrolling). I was hoping to set the table height such that I would see at least 10 rows before scrolling. Is this doable?
Thanks!
This discussion has been closed.
Replies
Allan
Thanks for your reply! I have tried increasing the value of sScrollY, but nothing happens. However, lowering the value below 100px causes it to get smaller. I added iDisplayLength, set to 20, but increasing values of sScrollY still had no effect.
This what I'm current trying, to no avail...
[code]
$(document).ready(function() {
$('#osw-edit-version-control').dataTable( {
"bJQueryUI": true,
"aaSorting": [ [1,'asc'], [2,'asc'] ],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "500px",
"iDisplayLength": 20
} );
} );
[/code]
Allan
This issue I noticed even in this page http://datatables.net/ref#bScrollInfinite when I run the code in JS Bin. In the example given in that page, if I increase the sScrollY value to something like 300px or more, its not showing any scroll bar.
That does look like bug. There is no scrolling there because it isn't needed on the first draw, thus there is no way to trigger a scroll event on the element. DataTables should perhaps detect that and automatically add more rows to force scrolling.
The alternative is simply to add more rows to the first draw with iDisplayLength : http://live.datatables.net/utevak/edit .
The second alternative (because there is always more than one :-) ) is to use Scroller - although that is finite virtual scrolling rather than infinite scrolling.
Allan
I don't really understand I'm afraid, why what infinite scrolling only?
DataTables has three scrolling options:
- "Normal" scrolling where all nodes are in the DOM and scrolling works the same way as any only regular scrolling element.
- infinite scrolling when items are added as you get close to the end of the current display set (like how twitter and Facebook do infinite loading)
- Scroller, which Is a lot like normal scrolling but uses virtual scrolling techniques to improve performance.
Which one is best will depend on what interaction you want and how you want to implement it. Any suggestions for other scrolling interactions are very welcome!
Allan
To be honest I'm not a fan of the infinite scrolling and I've considered dropping it from future versions - I won't for a while, and there would be at least one or two major versions where it is deprecated first - but as a user having the scroll bar jump around on a finite data set seems a bit odd. Scroller is effectively designed to address this problem - but then as you might expect, DataTables can only work with the data it is given, so column adjustment might be required there as well.
Thanks,
Allan
Using the test page on http://live.datatables.net/utevak/edit with the following settings you can see the problem.
{
"bScrollInfinite": true,
"bScrollCollapse": false,
"sScrollY": "400px",
"iDisplayLength": 10
}
Any workarounds for this?