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?

chimchim Posts: 3Questions: 2Answers: 0
edited February 26 in Free community support

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

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    DataTables itself doesn't support reading HTML like that. It doesn't support colspan or rowspan 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

Sign In or Register to comment.