How to have Buttons along with Entries Per Page?

How to have Buttons along with Entries Per Page?

Nevada SmithNevada Smith Posts: 8Questions: 2Answers: 0

This code snippet will show the Buttons, but not the Entries Per Page control:

        $('#example').DataTable( {
             paging: true,
             lengthMenu: [10, 25, 50, 100, -1],
             buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
             layout: {
                topStart: 'buttons'
             },

When I comment-out "topStart: 'buttons'" the Entries Per Page control appears sans buttons of course.

What does one have to do in order to have both Buttons and the Entries Per Page control to simultaneously appear?

Answers

  • Nevada SmithNevada Smith Posts: 8Questions: 2Answers: 0

    Found the answer here:

    https://datatables.net/reference/option/layout

    For my needs, I copied/edited the code for "Multiple elements on a row:"

    // Remove the defaults
    DataTable.defaults.layout = {
      topStart: null,
      topEnd: null,
      bottomStart: null,
      bottomEnd: null
    };
    
    $('#example').DataTable( {
       buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
       layout: {
          top: ['pageLength', 'buttons', 'search'],
          bottomStart: 'info',
          bottomEnd: 'paging'
       },
    ...
    
  • allanallan Posts: 65,277Questions: 1Answers: 10,821 Site admin

    Perfect - good to hear you found the answer :). There is also information about this in the FAQs.

    Allan

Sign In or Register to comment.