How to add a new row which is exportable

How to add a new row which is exportable

emmKayemmKay Posts: 5Questions: 1Answers: 0

Hey guys, I am generating a grid from the backend and then adding 2 rows to it via jQuery.
Following this, I am applying DataTable() to my table.

The table renders correctly, however, when I try to export it to Excel/PDF/CSv/Other, it does not export the 2 rows I added via Jquery.

Any suggestions why? Code as below:

    //add 2 columns in thead
    $("#dgResults thead").prepend('<tr><th colspan=' + colcount + '>' + $("#lblLocations").text() + '</th></tr><tr><th colspan=' + colcount + '>' + $("#lblQuestionnaire").text() + '</th></tr>');

    var table = $("#dgResults").DataTable(
    {
        "paging": true,
        "lengthChange": true,
        "pageLength": 25,
        "bSort": false,
        dom: 'lBfrtip',
        buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
    });

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    Answer ✓

    Looks like you are adding two rows to the thead. Datatables only supports exporting one table header row.

    Kevin

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Yup - for the moment. We are working on addressing that, but its a long term thing.

    Allan

  • emmKayemmKay Posts: 5Questions: 1Answers: 0

    Great, thank you for that. I will think up a workaround.

This discussion has been closed.