DataTable: Hide the Show Entries dropdown but keep the Search box

后端 未结 13 1423
再見小時候
再見小時候 2021-01-29 23:55

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 d

相关标签:
13条回答
  • 2021-01-30 00:13
    "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
    
    0 讨论(0)
  • 2021-01-30 00:14

    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

    0 讨论(0)
  • 2021-01-30 00:15

    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 });
    });
    

    Hope that helps !

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

    0 讨论(0)
  • 2021-01-30 00:16

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

    $('#example').dataTable( {
      "lengthChange": false
    });
    
    0 讨论(0)
  • 2021-01-30 00:16

    Just write :

      $(document).ready( function () {
            $('#example').dataTable( {
              "lengthChange": false
            } );
        } );
    
    0 讨论(0)
  • 2021-01-30 00:18

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

    0 讨论(0)
提交回复
热议问题