Set default page length option to 100 (show entries)
Set default page length option to 100 (show entries)
thatgreg
Posts: 6Questions: 4Answers: 0
in DataTables
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
This discussion has been closed.
Answers
What are the errors?
You will want to use the
pageLength
option to set the initial page length.Kevin
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.
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
Thanks for sharing the link @kthorngren, it really helped me.