JQuery Datatable PDF / Excel导出无法与服务器端处理一起使用

时间:2014-09-16 14:04:17

标签: jquery

我遇到数据表导出功能问题,当我使用下面的代码时

$('#example').dataTable({
    "sDom": 'T<"clear">lfrtip',
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "oTableTools": {
        "aButtons": [
            "copy",
            "csv",
            {
                "sExtends": "xls",
                "sxlsMessage": "Excel title"
            },
            {
                "sExtends": "pdf",
                "sPdfOrientation": "landscape",
                "sPdfMessage": "Pdf Title",
                "sPdfTitle": document.title
            },
            "print"
        ]
    }

这对我来说很好,但绑定数据与服务器端处理为true,我的表加载它所有数据,分页,排序和所有功能都工作但导出功能不起作用,实际导出按钮也没有显示,它也不是在DOM中加载。

$('#example').dataTable({
    "bJQueryUI": true,      
    "oTableTools": {
        "aButtons": [
            "copy",
            "csv",
            {
                "sExtends": "xls",
                "sxlsMessage": "Excel title"
            },
            {
                "sExtends": "pdf",
                "sPdfOrientation": "landscape",
                "sPdfMessage": "Pdf title",
                "sPdfTitle": document.title
            },
            "print"
        ]
    },
    "iDisplayLength": 10,
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "ServerData/AjaxPage.aspx",
    "aoColumns": [
        { "mData": "STATUS" }, 

1 个答案:

答案 0 :(得分:0)

您是否添加了tabletools脚本和css? 您还必须使用适当的选项初始化表 &#34; sSwfPath&#34;:&#34; /swf/copy_csv_xls_pdf.swf" https://datatables.net/extensions/tabletools/