jQuery DataTable Print Detail

jQuery DataTable Print Detail

josivanljosivanl Posts: 11Questions: 3Answers: 1

I have a datatable with original data and details data, this detail data can be expanded according to the user's wishes, however I have a printing problem, when I use the datatable print function, only the original data is printed, the detail data do not show.

I wonder if it is possible or not to print details. If it is not possible how best to display a detail in the same table so it can be printed?

This question has an accepted answers - jump to answer


  • kthorngrenkthorngren Posts: 2,452Questions: 19Answers: 553

    The detail display is generated on the fly from the rows data when the plus icon is clicked. One option is to add hidden columns to the table containing the detail data you want to export. For example if you have two detail rows and append them to the end of the table you could use this to hide them:

    columnDefs: [{ targets: [-1, -2], visible: false}]

    By default I believe the export buttons will export both visible and hidden columns.


  • josivanljosivanl Posts: 11Questions: 3Answers: 1

    Thanks for the answer, but what I really need is to print the detail in the way it presents itself, ie my detail is a table that contains a formatting of column sizes and spaces already defined.
    I did a lot of research and I could not understand how I can do a customization of the print button action so I can add the lines of detail along the original line.

    If you have any other suggestions for printing detail while maintaining formatting ??

  • josivanljosivanl Posts: 11Questions: 3Answers: 1
    Answer ✓

    I was able to solve my problem following this solution, where it indicates a way to do to always print the detail.


    I simply copied and understood the whole process. Apparently you do not have to change anything.

    Hope it helps someone!

  • MaycoMayco Posts: 2Questions: 0Answers: 0

    Hi Josivanl,
    I am trying to use your suggestion to print child row, but I have error when I click on Print button.
    script.js:90 Uncaught ReferenceError: dt_print is not defined
    at s.action (script.js:90)
    at q (dataTables.buttons.min.js:13)
    at HTMLButtonElement.<anonymous> (dataTables.buttons.min.js:14)
    at HTMLButtonElement.dispatch (jquery-3.2.1.js:5206)
    at HTMLButtonElement.elemData.handle (jquery-3.2.1.js:5014)

    I edited the buttons.print.js.

Sign In or Register to comment.