Using the “buttons” feature to export data (print or excel) is repeating last row in the table

Using the “buttons” feature to export data (print or excel) is repeating last row in the table

msimmonsmsimmons Posts: 11Questions: 5Answers: 0

I've used DataTables.net tables in a few other places but in this particular table I have an unknown set of columns at design time. Even so, I can't spot what is different about this implementation as far as the DataTables.net table is concerned.

The table itself works as expected, until I hit print (or excel) at which point I receive the last row repeated for the row count.

I have made a Fiddle demonstrating the issue: https://jsfiddle.net/vod2x3vk/4/

Thank you,
Michael

This question has an accepted answers - jump to answer

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49
    edited June 2016 Answer ✓

    I believe it has something to do with the loop when adding rows to table. I changed up the code and got it to work https://jsfiddle.net/vod2x3vk/5/

  • msimmonsmsimmons Posts: 11Questions: 5Answers: 0
    edited June 2016

    Hi, sorry for the delayed response, I didn't receive any notice that I had a reply.

    Is there a way to make the "columns" parameter of the table declaration an object as well?

    Basically I don't know what the columns will be ahead of time, they are dictated by the "fObject" that is dynamically built.

    (actually I figured it out, I just added a columns section that mirrors my header section and replaced the word "key" with data.)

    thanks for the help!!

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    Cool. I was actually tweaking my example when I got the email that you accepted my answer.

  • msimmonsmsimmons Posts: 11Questions: 5Answers: 0

    Thanks again, I just updated my live code (which is a bit more complex) and it is all working properly!

  • msimmonsmsimmons Posts: 11Questions: 5Answers: 0

    @jr42.gordon - I have a new table that I had to change to this way of adding the rows (it seems dynamic columns and printing doesn't play well with the way I learned to build these tables).
    My issue now is that this new table has "child rows" that need to be hidden by default and displayed on click. The child rows contain the same columns as the parents.

    I can't seem to find how to "mark" the child rows as such using this method of loading the data, do you know?

This discussion has been closed.