DataTable: Hide the Show Entries dropdown but keep the Search box
Asked Answered
F

16

172

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.

Farflung answered 8/11, 2012 at 14:10 Comment(0)
S
351

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 :)

Speck answered 8/3, 2013 at 2:6 Comment(0)
C
87

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

$('#example').dataTable( {
  "lengthChange": false
});
Creeps answered 28/10, 2016 at 18:40 Comment(1)
Yes, documented here: datatables.net/reference/option/lengthChangeViperish
O
50
"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
Ogdon answered 27/6, 2017 at 11:6 Comment(0)
I
24

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

Italianate answered 10/2, 2015 at 14:48 Comment(0)
A
14

I solve it like that. Use bootstrap 4

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

cdn js:

cdn css:

Ardath answered 4/10, 2018 at 16:54 Comment(1)
This works for datatables in 2018, none of the other did.Staunch
F
11

Just write :

  $(document).ready( function () {
        $('#example').dataTable( {
          "lengthChange": false
        } );
    } );
Forestaysail answered 22/4, 2019 at 7:8 Comment(0)
U
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

Umbrian answered 19/5, 2016 at 0:43 Comment(1)
this is better because it remove the div holdint the element . with bLenghChange element is gone but there is whitespace . thanks !Simas
D
8

sDom: "Tfrtip" or via a callback:

"fnHeaderCallback": function(){
    $('#YOURTABLENAME-table_length').hide();
}
Dismissal answered 9/1, 2013 at 16:53 Comment(0)
B
7

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

$('#example').DataTable({
    dom: 'Bfrtip'
})
Balloon answered 7/7, 2016 at 10:39 Comment(0)
K
5

You can try this also.

simply hide it from CSS by using,

 .dataTables_length {
        display: none;
    }

Both will work.

Kinsley answered 9/2, 2018 at 8:59 Comment(0)
T
1

Add this option:

"bInfo": false
Thorncombe answered 3/2, 2016 at 23:19 Comment(0)
P
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
Peradventure answered 3/3, 2016 at 16:15 Comment(0)
N
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.

Negris answered 25/11, 2015 at 15:24 Comment(0)
N
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

Nappe answered 25/2, 2021 at 12:1 Comment(0)
M
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.

Mansfield answered 10/8, 2022 at 8:46 Comment(0)
D
0

enter image description here Remove the top info bar

$(".dataTables_info").eq(0).parent().parent().remove()
Dorolice answered 17/4, 2024 at 12:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.