Child.hide() is also removing element from dom

Child.hide() is also removing element from dom

MaikelMaikel Posts: 75Questions: 18Answers: 1

Hey,

looking at this example
https://datatables.net/examples/api/row_details.html

it seems that row.child().hide() is also removing the chld from the DOM, but according to the API the .hide() should only hide it, and the .remove() should remove it from the DOM.

or am i missing something here?
Basically i want to use th child rows, but i don't want to remove it from the DOM if we close it.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    I think the working might be poor in the documentation - sorry! Both will remove the child row from the DOM (there is no option to have it not displayed, but still in the DOM), but row().child.remove() will destroy the contents of the old child row, while row().child.hide() will retain the child row in memory, allowing it to be shown again.

    I'll try to reword the documentation to make that clearer!

    Allan

  • MaikelMaikel Posts: 75Questions: 18Answers: 1

    hmm,

    is there an api to check if the child is already created or not?
    so i don't need to do the json request when its already created?
    is there a way to know this?

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Answer ✓

    is there an api to check if the child is already created or not?

    Yes - row().child() can be used to terminate if there are children for a row.

    Allan

This discussion has been closed.