How to show the Export buttons inside a bootstrap modal?

How to show the Export buttons inside a bootstrap modal?

ganji.chetanganji.chetan Posts: 2Questions: 1Answers: 0
edited April 2017 in Free community support

Hi,
I want to use 3 export buttons - Excel, PDF, Copy (HTML5 Version). There will be a Options button on the page, when user clicks on the Options button, one bootstrap modal should pop up and user should see the above 3 buttons inside the modal.

What is the best way to achieve this result?

Code looks like in the comment below.

Thanks in advance.

Regards.

Answers

  • ganji.chetanganji.chetan Posts: 2Questions: 1Answers: 0
    edited April 2017

    <!DOCTYPE html>
    <html>
    <head>
    <title>Data Table Example</title>

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" rel="stylesheet">
    

    </head>
    <body>

    Options
    First name Last name Position Office Age Start date Salary Extn. E-mail
    Tiger Nixon System Architect Edinburgh 61 2011/04/25 $320,800 5421 t.nixon@datatables.net
    Garrett Winters Accountant Tokyo 63 2011/07/25 $170,750 8422 g.winters@datatables.net
    Ashton Cox Junior Technical Author San Francisco 66 2009/01/12 $86,000 1562 a.cox@datatables.net
    Cedric Kelly Senior Javascript Developer Edinburgh 22 2012/03/29 $433,060 6224 c.kelly@datatables.net
    Airi Satou Accountant Tokyo 33 2008/11/28 $162,700 5407 a.satou@datatables.net









    var dataTable = $('#example').DataTable({ "sDom": "<'exportOptions text-right'B><'table-responsive't><'row'<p>>", "scrollCollapse": true, "paging": true, // "bSort": true, "info": false, buttons: [ { extend: 'excelHtml5', text: 'Excel', className: 'btn btn-primary', title: 'Data export', // titleAttr: 'Export all rows to Excel file', }, { extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-primary', orientation: 'landscape', title: 'Data export', // titleAttr: 'Export all rows to PDF file', // pageSize: 'LEGAL' }, { extend: 'copyHtml5', text: 'Copy Data', className: 'btn btn-primary', // titleAttr: 'Copy all rows to clipboard', }, ], });

    </body>
    </html>

  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    You want a DataTable inside a modal which has the export buttons? You'd do it in exactly the same way as you would with a DataTable inside a modal. Just initialise it when you create the modal.

    Allan

This discussion has been closed.