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: 13,577Questions: 25Answers: 3,193

    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 20

    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: 13,577Questions: 25Answers: 3,193

    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

Sign In or Register to comment.