Datatables Scroller in CakePHP 3 Using jQuery, Ajax, MySQL and Bootstrap 3
In this tutorial we are going to see how to integrate Datatables Scroller in CakePHP 3 using jQuery, Ajax, MySQL and Bootstrap 3. This Datatables Scroller will render millions of data within the datatables itself while Scrolling as per browser Viewport.
This Datatables Scroller will make ajax request and get the data from backend (CakePHP 3 & MYSQL) on demand as per the Scroller Viewport. So this prevents need of pagination, improves performance and reduces user effort. This exactly gives feel like Checking Facebook status on Facebook timeline.

Step 1: Create CakePHP 3 Controller and Actions for Datatables Scroller:
Please create two actions (scroller & ajaxEmployeesAction ) in the EmployeesController. One ( scroller) for normal view rendering, another one is ajax action (ajaxEmployeesAction) which handles ajax request that comes from frontend.
Step 2: Add Required Assets (jQuery, DataTables) for Responsive DataTables Scroller With Ajax Pagination:
Please include necessary assets files (jQuery, CSS and Datatables libraries) in your layout file to implement Datatables Scroller in CakePHP 3.
Please refer Basic Datatables Implementation in CakePHP 3 using static JSON data, jQuery and Bootstrap 3 tutorial to create CakePHP 3 layout file.
Step 3: Create View File for Datatables Scroller with Search Filter in CakePHP 3 :
Next create view file (scroller.ctp) in the following location src/Template/Employees directory. Add the following same HTML markup in that file.
Step 4: Initialize Datatables Scroller in CakePHP 3 Using jQuery :
Now initialize the Datatables Scroller using DataTable() function by selecting table ID…
Where
deferRender – this will create the DOM and render the data when user scrolls down
scrollY – this will enable vertical scrolling in DataTables.
loadingIndicator – this will enable the loading indicator while data is requested
Note : Please add following CSS change in your CSS file, This will fix data loading issue.
Step 5: Enable Datatables Scroller stateSave Functionality:
This will save the state of a table (its paging position, ordering state etc), so that is can be restored when the user reloads a page, or comes back to the page after visiting a sub-page. This state saving ability is enabled by the stateSave option.
Step 6: Initialize Datatables Scroller scrollTo Functionality:
If you enable Datatables Scroller scrollTo functionality, then on page load Datatables Scroll to a specific row mentioned during Initialization.
Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts
If you want any of my script need to be customized according to your business requirement,
Please feel free to contact me [at] muni2explore[at]gmail.com
Note: But it will be charged based on your customization requirement