como puedo agrupar columnas de la tabla y que se reflejen al exportar el pdf?

como puedo agrupar columnas de la tabla y que se reflejen al exportar el pdf?

Neroxx96Neroxx96 Posts: 2Questions: 1Answers: 0

he agrupado varias columnas en el datatables pero cuando le doy a exportar no refleja las agrupaciones en el pdf, hay alguna manera de que tambien se vean en el pdf? aqui un fragmento del codigo.

var groupColumn = 0;
let table = new DataTable("#Report", {

columnDefs: [{ visible: false, targets: groupColumn }],
order: [[groupColumn, 'asc']],
drawCallback: function (settings) {
    var api = this.api();
    var rows = api.rows({ page: 'current' }).nodes();
    var last = null;

    api.column(groupColumn, { page: 'current' })
        .data()
        .each(function (group, i) {
            if (last !== group) {
                $(rows)
                    .eq(i)
                    .before(
                        '<tr class="group"><td colspan="5">' +
                            group +
                            '</td></tr>'
                    );

                last = group;
            }
        });
},

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,993Questions: 26Answers: 4,887
    Answer ✓

    How can I group columns of the table and have them reflected when exporting the pdf?
    I have grouped several columns in the datatables but when I give to export does not reflect the groupings in the pdf, is there any way to also be seen in the pdf? here a fragment of the code.

    Datatables doesn't provide this capability. It will take a custom solution. I built an example of exporting the RowGroup extension rows to Excel in this thread. The code you have above is the precursor to the RowGroup extension.

    Kevin

  • Neroxx96Neroxx96 Posts: 2Questions: 1Answers: 0

    Me lo imagine pero de todos modos muchas gracias :)

Sign In or Register to comment.