How to call Datatable csv button from custom button

前端 未结 4 1991
攒了一身酷
攒了一身酷 2021-01-02 13:34

Need to call csv button from my custom button.

4条回答
  •  盖世英雄少女心
    2021-01-02 14:17

    At last i found the solution.

    In Datatable configuration , i added click event for the button to be triggered.

    buttons: [
            { 
                extend: 'csv',
            }
        ]
    
    $("#ExportReporttoExcel").on("click", function() {
        table.button( '.buttons-csv' ).trigger();
    });
    

    This works fine for me thanks for the comments and answers

提交回复
热议问题