How to make nested tree table using sortable js?

Viewed 26

enter image description hereInfo: I want to make nested draggable table using sortable js. This is like a tree table. The .detail-view tr is a child of previous tr or which have Parent data. I want If user Drag the parent tr the child(.detail-view) also dragged along with it. each parent tr have there separate zone with there child table.

The childs are not shared able with other childs or parents.

https://jsfiddle.net/47r95hbs/

<table class="table" id="mytable">
    <thead>
        <tr>
            <th>Sortable Table</th>
        </tr>
    </thead>
    <tbody id="ptable">
        <tr>
            <td>Parent subject 1</td>
        </tr>
        <tr class="detail-view" data-subject="1">
            <td>
                <table class="table detail-table">
                    <tbody>
                        <tr data-id="1">
                            <td>Subject 1 child</td>
                        </tr>
                        <tr data-id="2">
                            <td>Subject 1 child</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td>Parent subject 2</td>
        </tr>
        <tr class="detail-view" data-subject="2">
            <td>
                <table class="table detail-table">
                    <tbody>
                        <tr data-id="1">
                            <td>Subject 2 child</td>
                        </tr>
                        <tr data-id="2">
                            <td>Subject 2 child</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td>Parent subject 3</td>
        </tr>
        <tr class="detail-view" data-subject="2">
            <td>
                <table class="table detail-table">
                    <tbody>
                        <tr data-id="1">
                            <td>Subject 3 child</td>
                        </tr>
                        <tr data-id="2">
                            <td>Subject 3 child</td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
0 Answers
Related