Data Table buttons not showing

Data Table buttons not showing

x2noex2noe Posts: 6Questions: 2Answers: 0

the data tables buttons not showing unless i select an option from a drop down then the buttons appear. Is there a way to have the buttons showing without having to select an option from a drop down.

$(document).ready(function() {
    var formD = document.getElementById('from_date').value;
    var toD   = document.getElementById('to_date').value;
    var comp  = document.getElementById('company').value;
    // var com  = document.getElementById('company').options[comp].text;
//   var curN = document.getElementById('currency').value;
//     var curR = document.getElementById('currency').options[curN].text;
    $('#content').DataTable( {
        dom: 'Bfrtip',
        lengthMenu: [
            [ 10, 25, 50, -1 ],
            [ '10 rows', '25 rows', '50 rows', 'Show all' ]
        ],
        buttons: [
            'pageLength',
            'copyHtml5',
           
            {
                extend: 'excelHtml5',
                title: 'X2 Pay Account Statement',
                 messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r  From Date: '+formD+' To Date: '+toD
            },
           {
                extend: 'csvHtml5',
                title: 'X2 Pay Account Statement',
                 messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r  From Date: '+formD+' To Date: '+toD
    
            },
           
             {
                // extend: 'pdfHtml5',
                // orientation: 'landscape',
                // download: 'open',
                // pageSize: 'LEGAL',
                // title: 'X2 Pay Account Statement',
                //  messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r  From Date: '+formD+' To Date: '+toD+' \n\r Currency : '+ curR
                extend: 'pdfHtml5',
                orientation: 'landscape',
                download: 'open',
                pageSize: 'LEGAL',
                title: 'X2 Pay Account Statement',
                footer: true,
                customize: function(doc){
                    doc['footer']=(function(page, pages) {
                    return {
                    columns: [
                              '',
                    {
                      alignment: 'center',
                      text: [
                      { text: page.toString(), italics: true },
                       ' of ',
                      { text: pages.toString(), italics: true }
                        ]
                     }
                   ],
                       margin: [10, 10]
                  }
               });
                    
                    
            },
                
                 messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r  From Date: '+formD+' To Date: '+toD+' \n\r Company ID:'+ comp
                          
            }
        ]
    } );
} );

Answers

  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    unless i select an option from a drop down then the buttons appear

    What drop down? Can you link to a test page showing the issue please.

    Allan

  • x2noex2noe Posts: 6Questions: 2Answers: 0

    jsfiddle.net/noe_n/ucute16u

  • x2noex2noe Posts: 6Questions: 2Answers: 0

    so im using the data table buttons to save as pdf, csv, excel. I am using some javascript to pull out the information when the user selects a company, currency, date to display on the pdf but when you land on the page initially nothing will be selected so the buttons do not show until the user selects something but when the user lands on this specific page, all companies are shown so at the moment can not extract that information for all companies.

  • allanallan Posts: 63,160Questions: 1Answers: 10,406 Site admin

    Thanks for the jsfiddle, but its not actually running, giving Javascript errors. Can you link to a running test case showing the issue?

    Thanks,
    Allan

This discussion has been closed.