Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
}
like image 635
BAE Avatar asked Apr 18 '16 19:04

BAE


People also ask

What is Idisplaylength?

Show details. Number of rows to display on a single page when using pagination. If feature enabled (bLengthChange) then the end user will be able to override this to a custom setting using a pop-up menu.

How do you change the length of a Datatable?

len() method can still be used if you wish to programmatically change the page size and pageLength can be used to specify the initial page length.

How do I display only 5 records in a Datatable?

There is a option called pageLength . You can set this for show only 5 entries.


2 Answers

Use the below dom value,

dom: 'Blfrtip',
like image 61
shubomb Avatar answered Oct 04 '22 22:10

shubomb


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

like image 27
Baqer Naqvi Avatar answered Oct 04 '22 21:10

Baqer Naqvi