Copy, excel, and print buttons export all records rather than only the ones visible on the screen

Copy, excel, and print buttons export all records rather than only the ones visible on the screen

rdmrdm Posts: 192Questions: 54Answers: 4

In my scenario, I have some dropdowns that dynamically filter the visible records on the screen. That much is correct.

For example: g.change(function() { filterTable(); }); which triggers the following function.

function filterTable() {
    var t = $(".display").DataTable();
    t.destroy();
    $(".display").DataTable(config);

    // lots of more code...
    
    if (g.val().length > 0) {
        t.column(9).search(g.val());
    }
    

    t.draw();
}

However, when any of my three buttons are clicked, all records are exported rather than the filtered ones.

How do I need to configure my buttons so that they export only the visible records?

This is what I have so far. I figured I'd have to extend them but I can't find anything in the documentation to tell me how to extend the buttons.

buttons: ['copy', 'excelHtml5', 'print']

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.