Pagination and Scrolling - possible?
Pagination and Scrolling - possible?
Currently I am using the pagination with the default values of showing 10, 25, 50 or 100 items. The issue is if the user has say 80 items in the list and selects to show 100 items, the table displays off the end of the page. i.e. the Next/Previous buttons are lost and there is no scroll bar for the user to scroll down to the buttons. They can select 25 to fix the issue, but is there anyway to tell datatables I want to use pagination, but if the number of items shown is larger than the display area to give a vertical scrollbar?
Thanks, Wray
Answers
All I had to do is post the question to find the answer in the documentation.
$(document).ready(function() {
$('#example').DataTable( {
"scrollY": "200px",
"scrollCollapse"; true
} );
} );
The scrollY is the display area for the table, anything larger than that will cause a scroll bar to show up. The scrollCollapse means if the table fits in the display space don't show the scroll bar.
Yup - you can enable
scrollY
and keep pagination enabled as you have found. This combination is fairly useful when using server-side processing and setting a larger page length.Allan