How to get the current page of a datatable?

Asked

Viewed 359 times

-1

How to save the current page of a table to a php variable using the datatable plugin? For example: if I am on page two the variable should receive 2, if it is on page 3 the variable should receive 3 and so on.

  • 1

    Lucas, show us what you’ve tried to do, hardly anyone will do the job for you.

  • I don’t want you to do it for me, I just want to know the function of the datatable plugin that returns the page number.

1 answer

-1

There is a method called Page in Datatable that returns an integer with the value of the current page, I’m not sure how you are applying this so there is no way to specify in code its applicability, but I think this link below will help you.

Link page datatables

Any doubt I’m available.

  • Thanks Luiz Ferndando, this is what I need, but I want to save what comes back from the Page method in a php variable, is it possible? follows below the script of what I changed in datatable <script> $(Document). ready(Function() { $('#myTable').Datatable( { "language": { "paginate":{ "Previous": "Previous", "next": "Next" } } } ); } ); $. extend( true, $.fn.datatable.defaults, { "Searching": false, "Ordering": false, "pagingType": "simple", "info": false, "pageLength": 4, "lengthChange": false } ); </script>

  • I believe it would be something more or less like this: var pagina = Page(); but if I don’t get it, the syntax should be a little different

  • did this: var table = $('#myTable'). Datatable(); var pagina = table.page.info(); and then I echo the variable page where I want it to appear, but it is giving error of indefinite variable, you know how I can solve?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.