如何从jquery datatable将行数据复制到剪贴板?

时间:2018-06-07 08:49:26

标签: jquery datatable clipboard clipboarddata

其实我想要整理我的复制数据。复制到剪贴板正在复制所选行中的所有数据。但我想要特定的列数据。 所以,请帮我通过跳过一些列来复制数据。

This is the table and when the I select the row and click copy selected row then it's getting the total row data like below.

Here is the copied data pasted in excel. But I need some fields are skipped like below.

Like this specific result.

这是表格,当我选择行并单击复制选定行时,它将获得如下所示的总行数据。 以下是粘贴在excel中的复制数据。但我需要跳过一些字段,如下所示。 喜欢这个特定的结果。 这是我的数据表的脚本,请帮助我。

$(document).ready( function () {
    $('#myTable').DataTable({
        "scrollX": true,
        dom: 'B<"clear">lfrtip',
        columnDefs: [{
            "defaultContent": "None",
            render: function (data, type, full, meta) {
                if (type === 'copy') {
                    var api = new $.fn.dataTable.Api(meta.settings);
                    data = $(api.column(meta.col).header()).text() + ": " + data;
                }
                return data;
            }
        }],
        buttons: [{
            extend: 'copyHtml5',
            text: 'Copy Selected Rows',
            header: false,
            title: '',
            exportOptions: {
                modifier: {
                    selected: true
                },
                columns: ':visible',
                orthogonal: 'copy'
            }
        }, 'colvis'],
        "select": true,
        "lengthMenu": [ 10, 25, 50, 75, 100 ]
    });
} );

0 个答案:

没有答案