How to set the default number of rows displayed

How to set the default number of rows displayed

peterbrownepeterbrowne Posts: 314Questions: 54Answers: 0
edited November 2022 in DataTables 1.9

I have tried using "pageLength": 50, to set the fault number of records displayed in a datatables page, but it's not working. The page only displays 5 records per pagination. Any ideas?

var table = $( '#program_table' ).DataTable( {
                responsive: true,
                "pageLength": 50,
                columnDefs: [ {
                    targets: [1],
                    render: $.fn.dataTable.render.ellipsis( 100, true )
                } ],
                ajax: "program_data/program_data.php",
                dom: "Bfrtip",
                columns: [ {
                    data: "program_name"
                }, {
                    data: "program_details"
                }, {
                    data: "modified"
                }, {
                    data: "modified_by"
                } ],
                select: {
                    style: 'os',
                    selector: 'td:first-child'
                },
                buttons: []
            } );

Answers

  • peterbrownepeterbrowne Posts: 314Questions: 54Answers: 0

    Mmm, seems to be working now...

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    That's certainly the way to do it. Possibly you had state saving enabled or the browser was caching an old file.

    Allan

Sign In or Register to comment.