Topic: Datatable page number

vbdev premium asked 2 years ago


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;
                        });

Kamila Pieńkowska staff answered 2 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



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Premium
  • 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