169

Is it possible to hide the Show Entries dropdown but keep the Search box in DataTable? I want to always display 10 rows with pagination at the bottom along with search box but do not want to display the Show entries dropdown.

micstr
  • 5,080
  • 8
  • 48
  • 76
FaisalKhan
  • 2,406
  • 3
  • 25
  • 32

15 Answers15

350

You can find more information directly on this link: http://datatables.net/examples/basic_init/filter_only.html

$(document).ready(function() {
$('#example').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": true,
    "bInfo": false,
    "bAutoWidth": false });
});

EDIT : If you are lazy, "bLengthChange": false, is the one you need to change :)

starball
  • 20,030
  • 7
  • 43
  • 238
PERPO
  • 3,812
  • 1
  • 13
  • 20
86

If using Datatable > 1.1.0 then lengthChange option is what you need as below :

$('#example').dataTable( {
  "lengthChange": false
});
Jimmy Obonyo Abor
  • 7,335
  • 10
  • 43
  • 71
49
"searching": false,   // Search Box will Be Disabled

"ordering": false,    // Ordering (Sorting on Each Column)will Be Disabled

"info": true,         // Will show "1 to n of n entries" Text at bottom

"lengthChange": false // Will Disabled Record number per page
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
Niv
  • 491
  • 4
  • 2
24

This is key answer to this post "bLengthChange": false, will hide the Entries Dropdown

14

I solve it like that. Use bootstrap 4

    $(document).ready(function () {
        $('#table').DataTable({
            "searching": false,
            "paging": false,
            "info": false
        });
    });

cdn js:

cdn css:

shades3002
  • 879
  • 9
  • 11
11

Just write :

  $(document).ready( function () {
        $('#example').dataTable( {
          "lengthChange": false
        } );
    } );
proghasan
  • 425
  • 3
  • 20
10

For DataTables <=1.9, @perpo's answer

$('#example').dataTable({
    "bLengthChange": false
});

works fine, but for 1.10+ try this:

$('#example').dataTable({
    "dom": 'ftipr'
}); 

where we have left out l the "length changing input control"

1.9 Docs

1.10 Docs

Community
  • 1
  • 1
Michal Frystacky
  • 1,418
  • 21
  • 38
  • 1
    this is better because it remove the div holdint the element . with bLenghChange element is gone but there is whitespace . thanks ! – Hamid Salari Jul 19 '20 at 22:17
8

sDom: "Tfrtip" or via a callback:

"fnHeaderCallback": function(){
    $('#YOURTABLENAME-table_length').hide();
}
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
cnizzardini
  • 1,196
  • 1
  • 13
  • 29
7

To disable the "Show Entries" label, add the code dom: 'Bfrtip' or you can add "bInfo": false

$('#example').DataTable({
    dom: 'Bfrtip'
})
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
5

You can try this also.

simply hide it from CSS by using,

 .dataTables_length {
        display: none;
    }

Both will work.

Rupesh Kamble
  • 167
  • 3
  • 11
1

Add this option:

"bInfo": false
Peter Hall
  • 53,120
  • 14
  • 139
  • 204
code-8
  • 54,650
  • 106
  • 352
  • 604
1

To hide "show entries" but still have pagination. I used the code below and it worked.

"bPaginate": true,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"bAutoWidth": false
ejay56
  • 41
  • 7
0

To disable the "Show Entries" label, use "bInfo", example: "bFilter" is the search component, but are active by default.

$(document).ready( function () {
  $('#example').dataTable( {
    "bInfo": false
  } );
} );

Enable or disable the table information display. This shows information about the data that is currently visible on the page, including information about filtered data if that action is being performed.

steffanjj
  • 881
  • 9
  • 10
0

If you're using Angular you can use the following code to do the same.

in component.html

<table id="" datatable [dtOptions]="dtOptions" class="table dataTable">

and in your component.ts

 dtOptions: any = {}


 this.dtOptions = {
  searching: true,    //enables the search bar
  info: false        //disables the entry information
}

there more option for data table available please visit here to learn more

AMAL MOHAN N
  • 1,416
  • 2
  • 14
  • 26
0

for specific pages i suggest you use pure css --

.dataTables_filter, .dataTables_info, .dataTables_paginate, .dataTables_length 
    { 
     display: none;
    }

The above code will hide everything.