BAE
BAE

Reputation: 8936

jquery datatable: page length select list not shown

I am using JQuery Datatable: 1.10.7 and https://datatables.net/reference/option/lengthMenu

JS code:

      $('.table').dataTable({ 
'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All'] ], 
'aoColumns': [null, null, null, { 'bSortable': false }, { 'bSortable': false }] }); // eslint-disable-line new-cap

Output: enter image description here

But I need the following list to set page length:

enter image description here

How to do? Anything missing?

UPDATE

Output html:

<div id="DataTables_Table_0_length" class="dataTables_length">
   <label>
      Show 
      <select class="" aria-controls="DataTables_Table_0" name="DataTables_Table_0_length">
         <option value="10">10</option>
         <option value="25">25</option>
         <option value="50">50</option>
         <option value="-1">All</option>
      </select>
      entries
   </label>
</div>

But it is not shown at all.

UPDATE

The reason is:

.dataTables_length {
        display: none;
}

Upvotes: 8

Views: 27685

Answers (5)

Muhammad Faiq
Muhammad Faiq

Reputation: 69

Thanks to report, You can try the following way to solve it. Key point is to use dom:'Blfrtip'

 $('#tblClient').DataTable({
            dom: 'Blfrtip',
            buttons: [
                'colvis',
                'excel', {
                    extend: 'pdfHtml5',
                    exportOptions: {
                        columns: ':visible'
                    },
                    text: 'Download Pdf',
                    title: 'HCA Registration for Worker Portal',
                    orientation: 'landscape',
                    customize: function (doc) {
                        // Splice the image in after the header, but before the table
                        doc.content.splice(1, 0, {
                            margin: [0, 0, 0, 12],
                            alignment: 'center',
                            image: 'data:image/png;base64,iVBORw0KGgoAA..'

                        });

                    }
                }],
            'ordering': true,
            'searching': true,
            'info': true,
            "serverSide": false,
            "lengthMenu": [[50, 100 - 1], [50, 100, "All"]],
            "pageLength": 50,
..

Upvotes: 3

Baqer Naqvi
Baqer Naqvi

Reputation: 6514

You might be using Bfrtip as dom value. Try using Blfrtip. It will show Export buttons as well length menu.

Upvotes: 10

shubomb
shubomb

Reputation: 832

Use the below dom value,

dom: 'Blfrtip',

Upvotes: 31

Sodruldeen Mustapha
Sodruldeen Mustapha

Reputation: 1271

use id="datatable-keytable" in your table tag

Upvotes: 0

Erwin O.
Erwin O.

Reputation: 309

You need to specify where in the dom the datatable widget will show the page size.

There is the dom option, something like this:

$('.table').dataTable({ 
'lengthMenu': [ [10, 25, 50, -1], [10, 25, 50, 'All']     ], 
'aoColumns': [null, null, null, { 'bSortable': false }, { 'bSortable': false }]
dom:'<"yourcssstyle"l>'
});

https://datatables.net/reference/option/dom

Upvotes: 2

Related Questions