I am trying to sort an accordion table with sortable accordion tables inside!!! I really like how this layout looks but it has really been a challenge to figure out how to sort it.
I've tried working with this code: Sortable Accordion Table
but this sorts EVERY <tbody> in the table, including the sub-pieces.
I would really like to use sorttable: JQuery Sorttable
This code is smooth and works great! But it does a similar thing where it sorts ALL <tr> in that table, not just the "unhidden ones", but it doesn't sort past that table level.
Here is a link to Codepen to see a general layout of my table. Or for a very simple version:
<table class="fold-table">
<thead>
<tr>
<th>Company</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table class="fold-table">
<thead>
<tr>
<th>Company</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table>
<thead>
<tr>
<th>Company name</th>
<th>Customer no</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sony</td>
<td>13245</td>
</tr>
<tr>
<td>Sony</td>
<td>13288</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table>
<thead>
<tr>
<th>Company name</th>
<th>Customer no</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sony</td>
<td>13245</td>
</tr>
<tr>
<td>Sony</td>
<td>13288</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table class="fold-table">
<thead>
<tr>
<th>Company</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table>
<thead>
<tr>
<th>Company name</th>
<th>Customer no</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sony</td>
<td>13245</td>
</tr>
<tr>
<td>Sony</td>
<td>13288</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr class="view">
<td>Company Name</td>
<td class="pcs">457</td>
</tr>
<tr class="fold">
<td colspan="7">
<div class="fold-content">
<table>
<thead>
<tr>
<th>Company name</th>
<th>Customer no</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sony</td>
<td>13245</td>
</tr>
<tr>
<td>Sony</td>
<td>13288</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
Looking for ideas of how to refine these sorts to make then only sort one level of my table at a time.
Personally, I would just use DataTables with nested tables - should work basically out of the box.
Here is a fiddle that does exactly what you want to do with an added bonus of also including a "search" box by default: http://jsfiddle.net/headwinds/zz3cH/