How to hide the contents of a child line if the server generates not json, but HTML?
How to hide the contents of a child line if the server generates not json, but HTML?
chim
Posts: 3Questions: 2Answers: 0
The HTML code of the table is created on the server side and I need to understand what style and parameters need to be applied for the inserted child row and the table contained in it, to hide it.
Let's take the following example:
<table id="tbl">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>dob</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Jon</td>
<td>1983-04-03</td>
</tr>
<tr>
<td class="details-control dt-hasChild">2</td>
<td>Adam</td>
<td>1982-03-06</td>
</tr>
<tr data-dt-row="1" class="child-detail">
<td colspan="3">about</td>
</tr>
<tr>
<td>3</td>
<td>Kevin</td>
<td>1984-07-09</td>
</tr>
</tbody>
</table>
How do I hide a row with class 'child-detail'?
Answers
DataTables itself doesn't support reading HTML like that. It doesn't support
colspan
orrowspan
in the table body.The only way to have DataTables "start up" with HTML like that, wold be to use some custom Javascript to loop over the child rows, remove them (cache them somewhere for later use as a child row in DataTables) and then initialise the DataTable.
So it is possible, but it requires some extra work.
Allan