DataTable export button outside table

后端 未结 2 1307
南笙
南笙 2020-12-29 04:46

I have multiple tables on my web page and each one is a DataTable, it is working fine.

I want to enable the export to excel functionality on each of the datatable b

2条回答
  •  萌比男神i
    2020-12-29 05:11

    Initialize each tables buttons via a constructor, by that you can place the button elements in any container you want. If you want to place the buttons in a

    element outside the table, do this

    var buttons = new $.fn.dataTable.Buttons(table, {
         buttons: [
           'copyHtml5',
           'excelHtml5',
           'csvHtml5',
           'pdfHtml5'
        ]
    }).container().appendTo($('#buttons'));
    

    demo -> https://jsfiddle.net/qoqq3okg/

    I dont know your multiple tables setup, but now you just have to insert some elements along each

    element and inject buttons for each table into that element as described above.

    提交回复
    热议问题