Set default page length option to 100 (show entries)

Set default page length option to 100 (show entries)

thatgregthatgreg Posts: 6Questions: 4Answers: 0

My Code

Im trying to change the "show 10 entries" to show 100, All , 50, 10 (something like that) but default be 100.

I went to this help page https://datatables.net/examples/advanced_init/length_menu.html

but every time I implemented it into the JS code, I got errors.

$(document).ready(function() {
$('#example').DataTable( {
"lengthMenu": [[100, "All", 50, 25], [100, "All", 50, 25]]
} );
} );

thank you

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    What are the errors?

    You will want to use the pageLength option to set the initial page length.

    Kevin

  • thatgregthatgreg Posts: 6Questions: 4Answers: 0
    edited July 2021

    Not soo much an error
    but I added
    $('#example').dataTable( {
    "pageLength": 50
    } );

    and though the table did change to 50 results, data wasnt showing anymore.

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Your code snippet works in this example:
    http://live.datatables.net/sohuqovo/1/edit

    Did you look in the browser's console for errors?

    Can you post a link to your page or a test case showing the issue so we can help debug?

    Kevin

  • RahulRawatRahulRawat Posts: 1Questions: 0Answers: 0

    Thanks for sharing the link @kthorngren, it really helped me.

Sign In or Register to comment.