Mark rows as child rows

Mark rows as child rows

rapunzelrapunzel Posts: 2Questions: 1Answers: 0

Hello!
I want to use the datatables child rows feature. Say I already have a html table which looks like this:

<table>
  <tr>
    <td>A</td>
    <td>B</td>
  </tr>
  <tr class="child">
    <td>AA</td>
    <td>BB</td>
  </tr>
  <tr class="child">
    <td>AAA</td>
    <td>BBB</td>
  </tr>
  <tr>
    <td>C</td>
    <td>D</td>
  </tr>
</table>

And I want to have each tr element with class "child" as a child row of the previously defined tr without any class. Is that possible?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin
    Answer ✓

    No sorry - there is no option to initialise a DataTable from HTML, reading the child rows from the HTML. What you would need to do is get the child rows using jQuery before you initialise the DataTable and then add them to the parent row in the DataTable once it has been created.

    Allan

This discussion has been closed.