Add and Delete Child Rows on Click

Add and Delete Child Rows on Click

potato_codepotato_code Posts: 14Questions: 5Answers: 0

Hi,

I'm trying to add and delete a child row each time a button is clicked. I can get one child row to show but I can't delete nor add another child row.

Any help would be greatly appreciated. Thank you

Live Test Case:
live.datatables.net/kozuzema/12/

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925
    Answer ✓

    You are getting this error when clicking the delete row button:

    Uncaught ReferenceError: tr is not defined

    You need to find the Datatables row containing the child. There may be better ways to do this or you may need to alter the code for your production solution but this is one example of how to traverse the DOM to get to the Datatable tr. You can use the browser's inspector to see the DOM structure.

    http://live.datatables.net/kozuzema/13/edit

    Kevin

  • potato_codepotato_code Posts: 14Questions: 5Answers: 0

    Hi,

    Thanks for your answer. I thought this was the best way instead of add row since the child row data pertains to the parent row but I think I'm going to have to rethink my solution.

  • potato_codepotato_code Posts: 14Questions: 5Answers: 0

    Hi,

    Could I do an if /else statement where it checks if child row is already open. If it is open it adds another child row?

Sign In or Register to comment.