jQuery DataTables - TableTools。通过触发器 jQuery 激活按钮?

jQuery DataTables - TableTools. Activate buttons through trigger jQuery?

所以我使用 jQuery 数据表插件和 tabletools 来导出 .csv 文件。我不希望按钮可见,但我仍想通过页面其他位置的另一个下拉菜单访问这些功能。

我试过在 CSS 中隐藏 .DTTT_container class,然后在 jQuery 中触发点击事件:

$(".DTTT_button_csv").trigger("click");

但是它不保存 .csv 文件。
有办法吗?

这是我 dataTable()

的初始化代码
    var table = $("#table").dataTable({
        deferRender: true,
        sDom: "<'dt-toolbar'<'col-sm-6 col-xs-12 queryBreadcrumbs'>r<'col-xs-12 col-sm-6'Tf>>" +
            "t" +
            "<'dt-toolbar-footer'i>S",
        oTableTools: {
            aButtons: [
                "csv",
                {
                    sExtends: "pdf",
                    sTitle: "PDF",
                    sPdfMessage: "PDF Export",
                    sPdfSize: "letter"
                }, {
                    sExtends: "print",
                    sMessage: "Generated by ####### <i>(press Esc to close)</i>"
                }
            ],
            sSwfPath: ".../datatables/swf/copy_csv_xls_pdf.swf"
        },
        language: {
            searchPlaceholder: "Search",
            search: "_INPUT_" //no label
        },
        scrollY: scrollY,
        scrollCollapse: false,
        autoWidth: false,
        order: order
    });

简短回答:不可能,因为按钮 "Copy"、"CSV"、"Excel" 和 "PDF" 是使用 Adob​​e Flash 实现的。

请参阅 jQuery DataTables 作者 Allan Jardine 的 answer to this post

It's not possible I'm afraid. It's a security feature of Flash, so it can't trigger a file save or copy to clipboard without the user knowing it. It would be a huge problem if you could copy to clipboard on just a hover event!

替代解决方案是使用 jQuery table2excel, see for more details. Please note that plug-in may be in early stages of development and has some Excel format issues.