Datatable Hidden previous button on extend

Datatable Hidden previous button on extend

DangujbaDangujba Posts: 1Questions: 1Answers: 0

Hi! i am using datatable button for export. But when i try to extend the exportOptions for two buttons it only displaying the last button instead of all. Here is the code

<script>
  $(document).ready(function () {
    $('#product').DataTable({
        dom: 'Bfrtip',
        buttons: [
     
            {
                extend: 'excelHtml5',
                exportOptions: {
                    columns: [
                        0, 2, 3, 4, 5, 6, 7
                    ]
                },
                extend: 'pdfHtml5',
                exportOptions: {
                    columns: [
                        0, 2, 3, 4, 5, 6, 7
                    ]
                }
                
            }
        ]
    });
});
</script>

It only displaying the pdf button instead of both excel and pdf. Thanks

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Your two extends should be separated. You have effectively merged them.

    {
                    extend: 'excelHtml5',
                    exportOptions: {
                        columns: [
                            0, 2, 3, 4, 5, 6, 7
                        ]
                    },
    },  // end first extend
    {   // start second extend                                                                      v
                    extend: 'pdfHtml5',
                    exportOptions: {
                        columns: [
                            0, 2, 3, 4, 5, 6, 7
                        ]
                    }
                     
      }
    
  • rf1234rf1234 Posts: 2,933Questions: 87Answers: 415

    Have you tried the generic buttons "excel" and "pdf"?

  • rf1234rf1234 Posts: 2,933Questions: 87Answers: 415

    @tangerine is right. Didn't see that!

Sign In or Register to comment.