I have the following table setup:
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
<table>
<thead>
<tr>
<th>System Name</th>
<th>TotalSystemGB</th>
<th>Drive</th>
<th>Total GB</th>
<th>Used GB</th>
<th>Free GB</th>
</tr>
</thead>
<tbody>
<tr class="mainRow">
<td>System 1</td>
<td>1100</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="subRow">
<td> System 1</td>
<td></td>
<td>C:</td>
<td>100</td>
<td>50</td>
<td>50</td>
</tr>
<tr class="subRow">
<td> System 1</td>
<td></td>
<td>D:</td>
<td>1000</td>
<td>750</td>
<td>250</td>
</tr>
<tr class="mainRow">
<td>System 2</td>
<td>820</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="subRow">
<td> System 2</td>
<td></td>
<td>C:</td>
<td>120</td>
<td>70</td>
<td>50</td>
</tr>
<tr class="subRow">
<td> System 2</td>
<td></td>
<td>D:</td>
<td>700</td>
<td>500</td>
<td>200</td>
</tr>
<tr class="mainRow">
<td>System 3</td>
<td>3080</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="subRow">
<td> System 3</td>
<td></td>
<td>C:</td>
<td>80</td>
<td>30</td>
<td>50</td>
</tr>
<tr class="subRow">
<td> System 3</td>
<td></td>
<td>D:</td>
<td>1000</td>
<td>750</td>
<td>250</td>
</tr>
<tr class="subRow">
<td> System 3</td>
<td></td>
<td>E:</td>
<td>2000</td>
<td>1500</td>
<td>500</td>
</tr>
</tbody
</table>
I would like to have the following behaviour:
- When sorting on "System Name" and "TotalSystemGB" only the data gets sorted according to mainRows but the subRows remain attached correctly.
- When sorting on total, used or free GB the subRows get sorted only within the mainRows.
I currently use sortable but I don't see a way to make it work in the way I want it to, especially in regards of keeping the subRows attached to the mainRows.
Is there a clever way to solve this?