Scroller on AJAX sourced DT - Shouldnt it only render visible rows?
Scroller on AJAX sourced DT - Shouldnt it only render visible rows?
Im testing out the Scroller extension on a table using ajax
data source,
Heres the JSBin I setup, it logs all the data of the rows to the console via createdRow
.
You will see that it logs all of the rows when the page loads, but per the reference page:
What the virtual rendering means is that only the visible portion of the table (and a bit to either side to make the scrolling smooth) is drawn, while the scrolling container gives the visual impression that the whole table is visible.
Am I doing something wrong?...
Heres the exact JS:
$(document).ready( function () {
var table = $('#example').DataTable({
ajax: 'http://www.######.com/p/dt/dt_arrays.php',
deferRender: true,
scrollY: 200,
scrollCollapse: true,
lengthChange: false,
scroller: {
boundaryScale: 0.75,
displayBuffer: 20,
loadingIndicator: true
},
bInfo: true,
createdRow: function( row, data, dataIndex ) {
console.log('data',data);
}
});
} );
This question has an accepted answers - jump to answer
Answers
Bump :)
~6 rows showing, so the buffer is 120 rows (6*20) (the title description on in the
scroller.displayBuffer
documentation is wrong - the fix has already been committed, but the description below it is correct).Since there are only 57 records in the table, then yes, it will create all of them on the first pass since they are all being displayed.
If you change the display buffer to, say 5, then you will be able to see that only some of the rows are created: http://live.datatables.net/culuqaze/3/edit .
Allan
Perfect! I set the
scroller.displayBuffer
to 2, and it seems to work perfectly!I think I was assuming that it was expecting pixels as the value... no idea why I thought that.. DT doesnt use pixels for any settings >.<