How can I show child rows

How can I show child rows

jsmunroejsmunroe Posts: 1Questions: 1Answers: 0

I'm wanting to use the child rows feature, but I need them to be actual rows of the parent table. When I try to render the table with hidden rows datatables deletes those rows. The demo for the child rows feature shows adding a block of HTML under a row. I need to add additional rows.

I can do this with javascript, but datatables fights me on that. If I can't work with datatables, I'm just not going to use it with this task. Any ideas?

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    I'm wanting to use the child rows feature, but I need them to be actual rows of the parent table.

    Are you wanting these rows to be sortable and searchable by Datatables?

    When I try to render the table with hidden rows datatables deletes those rows.

    How are you hiding the rows? Datatables expects the rows to be visible and to use Datatables API's to manipulate them. Datatables doesn't know about table changes if they are manipulated directly in the DOM.

    The demo for the child rows feature shows adding a block of HTML under a row. I need to add additional rows.

    Use the row.add() for one row or rows.add() for multiple rows to add rows to the Datatable. Or if you want child rows that are not part of Datatables sorting and searching but look like the Datatable rows then see this thread about using return $('<tr>...</tr><tr>...</tr>').toArray();.

    Kevin

This discussion has been closed.