Tabletools初始化选项不适用

时间:2015-04-24 20:35:38

标签: jquery-datatables

我正在尝试向我的datatables / tabletools init添加一些设置但由于某些原因,无论我为tabletools更改了什么设置,默认选项仍然显示(即复制应该是>“复制到剪贴板”并且它仍然是“复制”)。当我点击它们起作用的按钮时,我知道它正在找到我的SWF。我正在使用最新版本的tabletools和datatables。

我尝试过两种古老的匈牙利符号:

"oTableTools": { "aButtons": [ {"sExtends": "copy", "sButtonText": "Copy to Clipboard", "mColumns": [1,2,3,4,5]}, {"sExtends": "print"}, {"sExtends": "csv", "columns": [1,2,3,4,5]}, {"sExtends": "pdf", "columns": [1,2,3,4,5]}, {"sExtends": "xls", "columns": [1,2,3,4,5]} ] }

以及

"tableTools": { "buttons": [ {"extends": "copy", "buttonText": "Copy to Clipboard", "columns": [1,2,3,4,5]}, {"extends": "print"}, {"extends": "csv", "columns": [1,2,3,4,5]}, {"extends": "pdf", "columns": [1,2,3,4,5]}, {"extends": "xls", "columns": [1,2,3,4,5]} ] }

我做错了吗?

由于

1 个答案:

答案 0 :(得分:1)

正确的初始化如下所示。请参阅TableTools example进行演示。

$('#example').DataTable( {
    "dom": 'T<"clear">lfrtip',
    "tableTools": {
        "aButtons": [
            {
                "sExtends": "copy",
                "sButtonText": "Copy to Clipboard",
                "mColumns": [1,2,3,4,5]
            },
            {
                "sExtends": "print"
            },
            {
                "sExtends": "csv",
                "mColumns": [1,2,3,4,5]
            },
            {
                "sExtends": "pdf",
                "mColumns": [1,2,3,4,5]
            },
            {
                "sExtends": "xls",
                "mColumns": [1,2,3,4,5]
            }
        ]
    }
} );