Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict between Bfrtip (buttons) and number dropdown

Here is my code for a datatables implementation:

<script type="text/javascript" src="../js/jquery-3.1.1.min.js" ></script>
<script type="text/javascript" src="../js/jquery-ui.js" ></script>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css" type="text/css" media="all">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.flash.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>

var table = $('#TransactionsTable').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'copy',
        'csv',
        'excel'
    ],
    "order": [[6, "desc"]],
    "columnDefs": [
       {
          "visible": false,
            "targets": [8]
       }
    ]
} );

I have a problem with the line "dom: 'Bfrtip',". If I include it, the buttons show, but the dropdown that allows you to select number of entries (e.g. show 10, 25, 50, 100 entries) disappears. If I remove that line the dropdown comes back but the buttons don't show. Why do I need to choose? How can I have both?

like image 856
Chiwda Avatar asked Dec 01 '22 10:12

Chiwda


2 Answers

Use dom: 'Blfrtip', to make the "per page" selector appear.

Notice I've included l there, it stands for length changing input control.

See the docs for more info.

like image 68
Phiter Avatar answered Dec 04 '22 07:12

Phiter


use dom: 'Blfrtip'. Note that there is an 'L' after B

like image 35
dvdopi Avatar answered Dec 04 '22 07:12

dvdopi