如何从数据表中的pdf中删除下拉选择选项 [英] How to remove dropdown select options from pdf in datatable

查看:139
本文介绍了如何从数据表中的pdf中删除下拉选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页脚的每一列中都包含了下拉菜单,在生成pdf时,所有选项都进入了页眉.导出时如何排除这些选项?

I have included dropdown to each column at footer, while generating pdf,all options are coming into header.how can we exclude these option while export?

这是我的代码:

$('#example').DataTable( {
    "dom": 'Bfirtlp',
    buttons: [

            {
            extend: 'excelHtml5',
            exportOptions: {
                columns: ':visible'
            }
            },
        {
            extend: 'pdfHtml5',
            orientation: 'landscape',
            pageSize: 'A3',
            exportOptions: {
                columns: [ 0, 1, 2,3,4,5,6,7,8],

            },
        ],
   initComplete: function () {
        this.api().columns().every( function () {
            var column = this;
             var eachHeader = $(column.header())[0];
             var headingVal = eachHeader.getAttribute("value");
             var select = $('<select class="btn btn-secondary btn-sm dropdown-toggle"><div class="dropdown-menu"><option  class="dropdown-item" value="">'+ headingVal +'</option><div></select>')
                .appendTo( $(column.footer()).empty() )
                .on( 'change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

                    column
                        .search( val ? '^'+val+'$' : '', true, false )
                        .draw();
                } );

            column.data().unique().sort().each( function ( d, j ) {
                select.append( '<option value="'+d+'">'+d+'</option>' )
            } );
        } );
    }
} );

推荐答案

我得到了解决方案,

包括此

exportOptions: { 
                format: {
                    header: function ( data, column, row )
                        {
                            return data.substring(data.indexOf("value")+9,data.indexOf("</option"));
                        }
                 }
            },

这篇关于如何从数据表中的pdf中删除下拉选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆