Topic: Datatable page number
Hello, we are using the datatables with pagination for a variable amount of data. And we combine the pagination with an auto-refresh mechanism. When the user is going from one page to another, at each refresh the pagination is back to page 1. We need to get the page number to avoid this issue
Expected behavior : getting the page number in a variable and select page from js after fetch
Actual behavior : the variable is not available
Resources (screenshots, code snippets etc.)
Here is how we do it with datagrid :
table = $('#datagrid').DataTable({'displayStart': (this_size * this_page), 'pageLength': this_size, 'search': {'search': this_search}});
$('#datagrid').on('page.dt', function () {
var info = table.page.info();
this_page = info.page;
});
kpienkowska staff answered 3 years ago
I've prepared snippet to show you how you can access info about active page.
In this example, I showed active page
with console.log
but you can use it however you need.
https://mdbootstrap.com/snippets/standard/kpienkowska/4109864
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.8.0
- Device: All
- Browser: All
- OS: All
- Provided sample code: No
- Provided link: No