Reputation: 339
Refer to the above image. I can sort/interchange Kerwin and Bonn in GROUP1. I can also interchange GROUPS. Now my problem is how can I sort/move Kerwin to other group. Example: move kerwin to group 2
Here's Demo + Code
$( ".content" ).sortable();
$( ".content" ).disableSelection();
$( ".subcontent" ).sortable();
$( ".subcontent" ).disableSelection();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<table id="subsortsortable">
<tbody class="content">
<tr><td>
<table>
<thead>GROUP 1</thead>
<tbody class="subcontent">
<tr><td>Kerwin</td></tr>
<tr><td>Bonn</td></tr>
</tbody>
</table>
</td></tr>
<tr><td>
<table>
<thead>GROUP 2</thead>
<tbody class="subcontent">
<tr><td>Ivan</td></tr>
<tr><td>Bobby</td></tr>
</tbody>
</table>
</td></tr>
<tr><td>
<table>
<thead>GROUP 3</thead>
<tbody class="subcontent">
<tr><td>Wil</td></tr>
<tr><td>Michael</td></tr>
</tbody>
</table>
</td></tr>
</tbody>
</table>
Upvotes: 1
Views: 342
Reputation: 15846
Use sortable({connectWith:['.subcontent']})
,
$( ".content" ).sortable({
dropOnEmpty: true
});
$( ".content" ).disableSelection();
$( ".subcontent" ).sortable({
connectWith:['.subcontent', '>*:not(.sort-disabled)'],
items:"tr[class!=sort-disabled]"
});
$( ".subcontent" ).disableSelection();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<table id="subsortsortable">
<tbody class="content">
<tr><td>
<table>
<thead>GROUP 1</thead>
<tbody class="subcontent">
<tr><td>Kerwin</td></tr>
<tr><td>Bonn</td></tr>
<tr class="sort-disabled"><td> </td></tr>
</tbody>
</table>
</td></tr>
<tr><td>
<table>
<thead>GROUP 2</thead>
<tbody class="subcontent">
<tr><td>Ivan</td></tr>
<tr><td>Bobby</td></tr>
<tr class="sort-disabled"><td> </td></tr>
</tbody>
</table>
</td></tr>
<tr><td>
<table>
<thead>GROUP 3</thead>
<tbody class="subcontent">
<tr><td>Wil</td></tr>
<tr><td>Michael</td></tr>
<tr class="sort-disabled"><td> </td></tr>
</tbody>
</table>
</td></tr>
</tbody>
</table>
Upvotes: 2