Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: MDB table component pagination initial page size

joel2 free asked 4 years ago


I am using the Datatable component with Table pagination.

I would like to change the default page size to 25. I have tried :


    $(document).ready(function () {
        $('#dtBasicExample').DataTable({
            "ordering": false
        });
        $('.dataTables_length').addClass('bs-select');
        $('select[name ="dtBasicExample_length"]').val("25");
    });

but while that sets the dropdown it does not change the page size.

Is there an option like?


$('#dtBasicExample').DataTable({
    "ordering": false,
    "pagingSize" : 25
});

Mateusz Łubianka staff answered 4 years ago


Hi @joel2,

Try to use this code:

<!-- Your custom scripts (optional) -->
  <script type="text/javascript">
    $(document).ready(function () {
      $('#dtBasicExample').DataTable({
        "pageLength": 50
      });
      $('.dataTables_length').addClass('bs-select');
    });
  </script>

I used it and it works fine.

Best,


joel2 free commented 4 years ago

Just the ticket Mateusz, works perfectly. Many thanks.


Mateusz Łubianka staff commented 4 years ago

I'm glad I could help.

Best,



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: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.11.0
  • Device: Laptop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No