Scroller is a plug-in for DataTables which enhances the "infinite scrolling" feature that DataTables has built-in to make the scrolling feel more natural. The scrolling box shown on the page is the full height of the drawn table, but a virtual rendering technique is used to only render the part of the table that is actually viewable in the scrolling viewport in order to increase the speed of drawing.
Note that Scroller assumes that all rows are of the same height (in order to preform the required calculations. You can use 'td { white-space: nowrap; }' in your CSS to ensure that text in rows does not wrap.
This example shows how Scroller for DataTables can be initialised by simply including the character 'S' in sDom (note that the 'S' must come after the 't' in sDom). Deferred rendering an and Ajax data source are also used in this example.
1 | Armand | Warren | 56045 | Taiwan, Province of China |
2 | Xenos | Salas | 71090 | Liberia |
3 | Virginia | Whitaker | 62723 | Nicaragua |
4 | Kato | Patrick | 97662 | Palau |
5 | Penelope | Hensley | 76634 | Greenland |
6 | Georgia | Erickson | 81358 | Bolivia |
7 | Shad | Pena | 20600 | Palestinian Territory, Occupied |
8 | Tanisha | Humphrey | 93371 | Kenya |
9 | Claire | Espinoza | I8S 2S8 | Panama |
10 | Raya | Tucker | O8D 8W7 | Botswana |
11 | Otto | Briggs | 57590 | Anguilla |
12 | Logan | Burt | 53041 | Venezuela |
13 | Cooper | Pennington | 36994 | France |
14 | Kristen | Peterson | 52917 | Sao Tome and Principe |
15 | Jordan | Velasquez | 08884 | Switzerland |
16 | Zelda | Freeman | F9H 1J9 | Holy See (Vatican City State) |
17 | Mary | Pacheco | A7Y 6X9 | Niger |
18 | Tiger | Robles | 44533 | Malaysia |
19 | Zelenia | Buckner | Q8N 6E5 | Malawi |
20 | Coby | Johnston | N6I 2O9 | Rwanda |
21 | Gillian | Strickland | 12258 | Cook Islands |
22 | Alfreda | Mcbride | K5A 3B6 | Nigeria |
23 | Laith | Ford | 19072 | Czech Republic |
24 | Autumn | Barton | U9D 9F4 | Angola |
25 | Nadine | Britt | G4U 8L0 | Liechtenstein |
26 | Xaviera | Hart | T1N 7D2 | Mali |
27 | Neil | Page | T3E 9F4 | Korea |
28 | Rose | French | B7T 8M2 | French Polynesia |
29 | Alyssa | Poole | S1L 2T5 | Yemen |
30 | Chantale | Lynch | 97316 | United States |
31 | Jermaine | Dawson | A3H 7A1 | American Samoa |
32 | Ann | Giles | 54258 | Korea |
33 | Jerry | Carr | 04901 | South Georgia and The South Sandwich Islands |
$(document).ready(function() { var oTable = $('#example').dataTable( { "sScrollY": "200px", "sAjaxSource": "media/data/2500.txt", "sDom": "frtiS", "bDeferRender": true } ); } );