Is there a way to add table rows with html?

Is there a way to add table rows with html?

chboccachbocca Posts: 90Questions: 14Answers: 1

Here is demo of simple row add function. When you click the "Add Rows" button it uses row().data() to copy the data from each row and then uses the row.add(data) to add new rows. But any formatting from the copied rows, like background color, is lost. Is there a similarly simple way to copy rows with the html intact and then add rows back in with html? Something like row().html() and row.add(html)? Thanks in advance, as always. c

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    row.add() can also take a node, so you can clone the existing nodes in the table and pass that in. See your example updated here: http://live.datatables.net/cuqofuco/1/edit

    Colin

  • chboccachbocca Posts: 90Questions: 14Answers: 1

    Beautiful. Thank you Colin.

    Here's updated demo.

    Stay well!

    c

  • FrandollowFrandollow Posts: 3Questions: 0Answers: 0

    I would like to know more about how to add table rows with HTML. Thank you!

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    What would you like to know that isn't shown in the demos / examples linked to above?

    Allan

This discussion has been closed.