Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery dataTables hide Show Entries text but show the dropdown list

Tags:

datatables

jQuery dataTables hide "Show Entries" text but show the dropdown list in right side of page.

$('#myTable_reports_view').DataTable({
   "aoColumnDefs": [
       {"bSortable": false, "aTargets": [2,3,4,5,7]}
   ],
   "bFilter": false,
   "bInfo": false,
   "bLengthChange": true
});

I am adding this code. The problem is "Show DDL entries" is getting hide but I want to hide the text part only, not the dropdown list.

like image 975
user3302950 Avatar asked Jul 23 '15 07:07

user3302950


People also ask

How do I hide and show columns in dataTable?

To hide and show columns use columns() and visible() method. Call it on dataTables instance and pass column index in columns() method and false to visible() method. Similarly, pass true to visible() if you want to show the columns.

How do I show only 5 entries in DataTables?

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

What are the salient features of DataTables in jquery?

DataTables will read all of the information about the table from the page (the DOM) and add features such as filtering, paging and sorting. This follows the basis for progressive enhancement where a table will be enhanced if JavaScript is available, and not if the browser doesn't have the required capabilities.


1 Answers

Yes, hiding the lengthmenu hides the text and the lengthmenu. If you just want to get rid of the "Show XX entries" text, then simply alter the language settings for that particular element. The default settings is :

"oLanguage": {
    "sLengthMenu": "Show _MENU_ entries"
}

reset that in your initialization :

$('#myTable_reports_view').DataTable({
   "bFilter": false,
   "bInfo": false,
   "bLengthChange": true,
   oLanguage: {
       sLengthMenu: "_MENU_",
    }
});

Now you will only have the dropdown, not the prefix / suffixes. Here is an extracted list of all oLanguage defaults :

"oLanguage": {
    "oAria": {
        "sSortAscending": ": activate to sort column ascending",
        "sSortDescending": ": activate to sort column descending"
    },
    "oPaginate": {
        "sFirst": "First",
        "sLast": "Last",
        "sNext": "Next",
        "sPrevious": "Previous"
    },
    "sEmptyTable": "No data available in table",
    "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
    "sInfoEmpty": "Showing 0 to 0 of 0 entries",
    "sInfoFiltered": "(filtered from _MAX_ total entries)",
    "sInfoPostFix": "",
    "sDecimal": "",
    "sThousands": ",",
    "sLengthMenu": "Show _MENU_ entries",
    "sLoadingRecords": "Loading...",
    "sProcessing": "Processing...",
    "sSearch": "Search:",
    "sSearchPlaceholder": "",
    "sUrl": "",
    "sZeroRecords": "No matching records found"
 }
like image 172
davidkonrad Avatar answered Sep 27 '22 22:09

davidkonrad