亲爱的StackOverflow用户,排序,以扩展表添加
现在我正在寻找这个问题的3天一个解决方案,我不能找到它在互联网上。我的工作是使管理面板添加发票。到目前为止,我所点击的是一张桌子,当你点击该行时,该桌子可以扩展,而我的目标是使其可排序。
$(function() {
$("tr.child-row").hide();
$("table").click(function(event) {
event.stopPropagation();
var $target = $(event.target);
if ($target.closest("td").attr("colspan") > 1) {
$target.slideUp();
} else {
$target.closest("tr").next().slideToggle();
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="table-responsive">
<table class="table table-poducts">
<thead>
<tr>
<th>
verbergen
</th>
<th>
Aantal
</th>
<th>
Verwijzing
</th>
<th>
Beschrijving
</th>
<th>
Angeboden prijs
</th>
<th>
Korting
</th>
<th>
Nieuwe prijs
</th>
<th>
Totaal
</th>
<th>
Acties
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" name="hide[]">
</td>
<td>
1
</td>
<td>
31516
</td>
<td>
DIGIDOT LED STRIP RGB HR 5m 24V BLACK PCB
</td>
<td class="text-right">
€285,00
</td>
<td class="text-right">
50%
</td>
<td class="text-right">
€142,50
</td>
<td class="text-right">
€142,50
</td>
<td>
<button id="btn">Click me</button>
</td>
</tr>
<tr class="child-row">
<td colspan="9">
<div id="test">
<table width="100%">
<tr>
<td width="50%">
<textarea></textarea>
</td>
<td width="50%">
<button class="btn btn-primary">kleine text</button>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="hide[]">
</td>
<td>
1
</td>
<td>
31516
</td>
<td>
DIGIDOT LED STRIP RGB HR 5m 24V BLACK PCB
</td>
<td class="text-right">
€285,00
</td>
<td class="text-right">
50%
</td>
<td class="text-right">
€142,50
</td>
<td class="text-right">
€142,50
</td>
<td>
<button id="btn">Click me</button>
</td>
</tr>
<tr class="child-row">
<td colspan="9">
<div id="test">
<table width="100%">
<tr>
<td width="50%">
<textarea></textarea>
</td>
<td width="50%">
<button class="btn btn-primary">kleine text</button>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
我的意思使它排序是,你可以将它拖放和表中的其他地方重新排序。
我希望有人能帮助我解决这个问题。
感谢您的关注。
虽然JSFiddle可以提供帮助,但在您的SO帖子中包含您的代码(仅限相关部分)是一种很好的做法。 – kalabalik
谢谢你的提示! –