Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2366

PDF Export: One Column has no content

$
0
0

Hi,

if i export my table with pdf, the third column has no content. Why? the third column contains only digits (e.g. 0,1,2,5,...).

HTML

                <table class="table table-bordered table-hover" cellspacing="0" width="100%" id="table_show_status">
                    <thead>
                        <tr>
                            <th>Datum</th>
                            <th>Uhrzeit</th>
                            <th>Fahrzeug</th>
                            <th>Status</th>
                            <th>Dauer [h:m:s]</th>
                            <th>id</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>Datum</th>
                            <th>Uhrzeit</th>
                            <th>Fahrzeug</th>
                            <th>Status</th>
                            <th>Dauer [h:m:s]</th>
                            <th>id</th>
                        </tr>
                    </tfoot>
                </table>

Javascript

    var table_show_status = $('#table_show_status').DataTable( {
        dom:    "<'row'<'col-sm-8'l><'col-sm-2'B><'col-sm-2'f>>" +
                    "<'row'<'col-sm-12'tr>>" +
                    "<'row'<'col-sm-5'i><'col-sm-7'p>>",
        buttons: [ {
            extend: 'pdf',
            exportOptions: {
                columns: [ 0, 1, 2, 3, 4 ]
            },
            text: 'PDF erstellen',
 
            
        } ],
        "lengthMenu": [ [10, 18, 50, -1], [10, 18, 50, "All"] ],
        "ajax": {
            "url": "ajax/table.show.status.php"
        },
        "language": { "url": "js/german.js"},
        "columns": [
            { "data": "date", "orderable": false },
            { "data": "time", "orderable": false, "searchable": false },
            { "data": "fahrzeug", "orderable": true },
            { "data": "status", "orderable": false },
            { "data": "dauer", "orderable": false, "searchable": false },
            { "data": "id", "visible": false, "searchable": false },
        ],
        "order": [ [ 5, 'DESC' ] ],
        
        "columnDefs": [ 
            {
                "render": function ( data, type, row ) {
                            return data + ' Uhr';
                },
                    
                "targets": [1]
        
            }
        ],
        "rowCallback": function( row, data, index ) {
            
            switch(data['status']){
                case 0:
                    $(row).addClass('danger').css('color', '#fff')
                    break;
                case 1:
                    $(row).addClass('warning')
                    break;
                case 2:
                    $(row).addClass('success')
                    break;
                case 3:
                    $(row).addClass('info')
                    break;
                case 4:
                    $(row).addClass('primary').css('color', '#fff')
                    break;
                case 5:
                    $(row).addClass('default')
                    break;
                case 6:
                    $(row).addClass('danger').css('color', '#fff')
                    break;
            }
        },
        "initComplete": function() {
            this.api().columns().every( function () {
                var column = this;
                var select = $('<select class="form-control input-sm"><option value=""></option></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>' )
                } );
            });
            check_for_new_status();
        }       
    });

Viewing all articles
Browse latest Browse all 2366

Trending Articles