Change title of export table, everytime I change dropdown in HTML

Change title of export table, everytime I change dropdown in HTML

alfianirdandialfianirdandi Posts: 2Questions: 1Answers: 0

So I want to change the title of table when I export, the title is changed everytime I change a dropdown in HTML. For more clear this is my code:

in HTML :
<select id="filter-cabang-saldo-atm" > <option>....</option> <option>....</option> <option>....</option> </select>

in Script:


var tb_saldo_atm = $("#tb_saldo_atm").DataTable({ "scrollX": true,"scrollCollapse": true, "columnDefs": [ { "searchable": false, "orderable": false, "targets": 0 } ],"order": [[ 3, 'asc' ]], "autoWidth": true, "lengthMenu": [[20, 50, 100, -1], [20, 50, 100, "All"]], dom: 'lBfrtip', buttons: [{extend: 'print',footer:true, text: 'Print',title:$("#judul_tabel_export").val()+' - '+$("#waktu_export").val()+$("#filter-cabang-saldo-atm option:selected").text(), exportOptions: { columns: [0,1,2,3,5], modifier: { selected: true } }} }} ] }); $('#filter-cabang-saldo-atm').on('change', function(){ tb_saldo_atm.column(5).search(this.value).draw(); tb_saldo_atm.rows().invalidate('dom'); });

Please help. Thanks before.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • alfianirdandialfianirdandi Posts: 2Questions: 1Answers: 0

    I have found the answer it should be use function.

    {extend: 'print',footer:true,
        text: 'Print',title:function () { return $("#judul_tabel_export").val()+
    ' - '+$('#filter-cabang-saldo-atm option:selected').text()+
    ' - '+'<?php echo date('d F Y'); ?>'; },
        exportOptions: {
            columns: [0,1,2,3,5],
            modifier: {
                selected: true
            }
        }}
    
    
This discussion has been closed.