Datatables tabletools复制过滤后的数据

时间:2015-02-03 19:15:03

标签: tabletools datatables-1.10

我想只复制tabletools插件中的过滤数据。我已经看过几次问这个问题,并且所有答案都说要使用oSelectorOpts。我相信我这样做但是它看起来并没有起作用。

$(document).ready(function() {
            var oTable = $('#SensorData').DataTable(
            {
                "order": [[2, "desc"]],
                dom: 'T<"clear">lfrtip',
                tableTools: {
                    "sSwfPath": "assets/swf/copy_csv_xls_pdf.swf"
                },
                "oTableTools": {
                    "aButtons": [
                        {
                            'sExtends': 'copy',
                            "oSelectorOpts": { filter: 'applied', order: 'current', page: 'all' },
                        },
                        {
                            'sExtends': 'xls',
                            "oSelectorOpts": { filter: 'applied', order: 'current' },
                        },
                        {
                            'sExtends': 'print',
                            "oSelectorOpts": { filter: 'applied', order: 'current' },
                        },
                        {
                            'sExtends': 'pdf',
                            "oSelectorOpts": { filter: 'applied', order: 'current' },
                        },
                        {
                            'sExtends': 'csv',
                            "oSelectorOpts": { filter: 'applied', order: 'current' },
                        }
                    ]
                },
                "columnDefs": [
                    {
                        "targets": [0],
                        "visible": false,
                        "searchable": false
                    }
                ]
            });

1 个答案:

答案 0 :(得分:0)

终于弄明白了。 我的邻接部分位于错误的区域。

var oTable = $('#SensorData').DataTable(
            {
                "bServerSide": false,
                "order": [[2, "desc"]],
                dom: 'T<"clear">lfrtip',
                tableTools: {
                    "sSwfPath": "assets/swf/copy_csv_xls_pdf.swf",
                    "aButtons": [
                        {
                            "sExtends": "copy",
                            "mColumns": [1, 2],
                            "oSelectorOpts": { filter: "applied", order: "current" }
                        },
                        {
                            'sExtends': 'xls',
                            "mColumns": [1, 2],
                            "oSelectorOpts": { filter: 'applied', order: 'current' }
                        },
                        {
                            'sExtends': 'print',
                            "mColumns": [1, 2],
                            "oSelectorOpts": { filter: 'applied', order: 'current' }
                        },
                        {
                            'sExtends': 'pdf',
                            "mColumns": [1, 2],
                            "oSelectorOpts": { filter: 'applied', order: 'current' }
                        },
                        {
                            'sExtends': 'csv',
                            "mColumns": [1, 2],
                            "oSelectorOpts": { filter: 'applied', order: 'current' }
                        }
                    ]
                },
                "columnDefs": [
                    {
                        "targets": [0],
                        "visible": false,
                        "searchable": false
                    }
                ]
            });