TableTools and child rows not export any data,

TableTools and child rows not export any data,

jadertcjadertc Posts: 2Questions: 0Answers: 0
edited November 2014 in Free community support

Good afternoon, I am trying to simultaneously place the code datatables, child rows "http://www.datatables.net/examples/api/row_details.html" and table tools for export in pdf and xls "https://www.datatables.net / extensions / tabletools / ", but I can not export my data ...
my two codes below ...

the js...

 <script type="text/javascript" language="javascript" class="init">

     function format ( d ) {
    // `d` is the original data object for the row
    return '<table class="table" cellpadding="1" cellspacing="1" border="0" style="padding-left:70px;">'+
        '<tr>'+
            '<td><b>Numero</b></td>'+
            '<td>'+d[14]+'</td>'+
            '<td><b>Preço unit:</b></td>'+
            '<td>'+d[16]+'</td>'+
            '<td><b>Vendedor:</b></td>'+
            '<td>'+d[24]+'</td>'+
            '<td><b>Natureza:</b></td>'+
            '<td>'+d[37]+'</td>'+

        '</tr>'+
            '<td><b>Razão:</b></td>'+
            '<td>'+d[12]+'</td>'+
            '<td><b>Código Cliente:</b></td>'+
            '<td>'+d[32]+'</td>'+
            '<td><b>Código Artigo Cliente:</b></td>'+
            '<td>'+d[35]+'</td>'+
            '<td><b>UF:</b></td>'+
            '<td>'+d[36]+'</td>'+
        '</tr>'+
            '<td><b>Arm 51:</b></td>'+
            '<td>'+d[41]+'</td>'+
            '<td><b>Arm 54:</b></td>'+
            '<td>'+d[44]+'</td>'+
            '<td><b>Arm 04:</b></td>'+
            '<td>'+d[40]+'</td>'+
            '<td><b>Arm 52:</b></td>'+
            '<td>'+d[42]+'</td>'+
            '<td><b>Arm 53:</b></td>'+
            '<td>'+d[43]+'</td>'+
            '<td><b>Arm 56:</b></td>'+
            '<td>'+d[45]+'</td>'+
        
        '</tr>'+

    '</table>';
}


       </script>

and


<!-- Java Script para criação da Tabela --> <script type="text/javascript" language="javascript" class="init"> $(document).ready(function() { var table = $('#dataTables-example').DataTable({ if ( aData[2] < aData[1] ) { $(nRow).css('color', 'red') } }, "bProcessing": true, "bStateSave": false, "sAjaxSource" : "server/server.php", "columns": [ { "class": 'details-control', "orderable": false, "data": null, "defaultContent": '' } ], "order": [[7, 'desc']], "columnDefs": [ { "targets": [ 12 ], "visible": false, "searchable": false }, { "targets": [ 13 ], "visible": false, "searchable": false }, { "targets": [ 14 ], "visible": false, "searchable": false } ] , "sDom": "<'row'<'col-lg-6'l><'col-lg-6'Tf>r>t<'row'<'col-lg-6'i><'col-lg-6'p>>", "oTableTools": { "aButtons": [ { "sExtends": "copy", // "sButtonText": "", "oSelectorOpts": { filter: 'applied', order: 'current' } }, { "sExtends": "xls", //"sButtonText": "", "oSelectorOpts": { filter: 'applied', order: 'current' }, "sFileName": "report.xls" }, { "sExtends": "pdf", //"sButtonText": "", "oSelectorOpts": { filter: 'applied', order: 'current' }, //"sFileName": "report.pdf", "sFieldSeperator": " ", "sAction": "flash_pdf", "sNewLine": "\n", "sFileName": "*.pdf", "sRowSelector": "td:not(:first-child)", //"sPdfMessage": "Account List" + ($('div.dataTables_filter input').length > 0 ? " Filter: " + $('div.dataTables_filter input').val() : "") "fnClick": function( nButton, oConfig, flash ) { this.fnSetText( flash, "title:"+ this.fnGetTitle(oConfig) +"\n"+ "message:"+ oConfig.sPdfMessage +"\n"+ "colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+ "orientation:"+ oConfig.sPdfOrientation +"\n"+ "size:"+ oConfig.sPdfSize +"\n"+ "--/TableToolsOpts--\n" + this.fnGetTableData(oConfig) ); } }, { "sExtends": "print", //"sButtonText": "", "oSelectorOpts": { filter: 'applied', order: 'current' }, }, ] } }); $('#dataTables-example tbody').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row( tr ); if ( row.child.isShown() ) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child( format(row.data()) ).show(); tr.addClass('shown'); } } ); <!-- FUNÇÃO ATUALIZAR AUTOMATICO NA BASE DE DADOS --> setInterval( function () { table.ajax.reload(); }, 180000 ); });

and the html code


<table id="dataTables-example" class="table table-striped table-hover" cellspacing="0" width="100%" > <thead> <tr> <th> </th> <th>campo 1</th> <th>campo 2</th> <th>campo 3</th> <th>campo 4</th> <th>campo 5</th> <th>campo 6</th> <th>campo 7</th> <th>campo 8</th> <th>campo 9</th> <th>campo 10</th> <th>campo 11</th> </tr> </thead> <tbody> <tr> <td colspan="5" class="dataTables_empty">Carregando Base de Dados</td> </tr> </tbody> </table>

thanks a lot

Replies

  • jadertcjadertc Posts: 2Questions: 0Answers: 0
    edited November 2014

    Hi, I'm resolv my question... the code is that...

      "columns": [
                {
                    "class":          "details-control",
                    "orderable":      false,
                    "data":           null,
                    "defaultContent": ""
                },
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                {
                  "data": null,
                  "orderable":      false,
                  "visible": false,
                  "defaultContent": ""
                },
                {
                  "data": null,
                  "orderable":      false,
                  "visible": false,
                  "defaultContent": ""
                },
                {
                  "data": null,
                  "orderable":      false,
                  "visible": false,
                  "defaultContent": ""
                },
                {
                  "data": null,
                  "visible": false,
                  "orderable":      false,
                  "defaultContent": ""
                },
                ],
    

    Thaks

This discussion has been closed.