Datatables can be made to scroll along the x and y axes. Include "`datatable-scroll`" in your `use()` line to enable the feature.
This example shows the basic scrolling configurations available.
Note: Scrolling is not currently supported on the Android WebKit browser.
Enable vertical scrolling by setting `scrollable` to "y" and assigning the `height`.
``` YUI().use('datatable-scroll', function (Y) { var state_census_data = [ ... ], table; {{>datatable-scroll-y-source}} }); ```Enable horizontal scrolling by setting `scrollable` to "x" and assigning the `width`.
``` YUI().use('datatable-scroll', function (Y) { var state_census_data = [ ... ], table; {{>datatable-scroll-x-source}} }); ```Enable scrolling along both axes by setting `scrollable` to `true` or "xy" and assigning both `height` and `width`.
``` YUI().use('datatable-scroll', function (Y) { var state_census_data = [ ... ], table; {{>datatable-scroll-xy-source}} }); ```Scrolling DataTables support percentage `width`s. The table above is configured to scroll vertically with a `width` of "100%".
``` YUI().use('datatable-scroll', function (Y) { var state_census_data = [ ... ], table; {{>datatable-scroll-pct-source}} }); ```This is the data that is used for each example table. The keys in each tables' `columns` correspond with the keys in the data.
``` var sampleData = [ { ANSI: "00000", STATE: "UNITED STATES", TOTAL_POP: 307006550, LAND_AREA: 3537438.44, POP_PER_SQ_MILE: 79.6 }, { ANSI: "01000", STATE: "ALABAMA", TOTAL_POP: 4708708, LAND_AREA: 50744, POP_PER_SQ_MILE: 87.6 }, { ANSI: "02000", STATE: "ALASKA", TOTAL_POP: 698473, LAND_AREA: 571951.26, POP_PER_SQ_MILE: 1.1 }, { ANSI: "04000", STATE: "ARIZONA", TOTAL_POP: 6595778, LAND_AREA: 113634.57, POP_PER_SQ_MILE: 45.2 }, ... ]; ```The values of `scrollable` and the respective dimensional attribute determine the scrolling direction(s) of each datatable instance.
Other things to consider are: