具有组合行的 jQuery 表排序器
抱歉这个标题,我不知道如何更好地描述它。
我有下表:
<tr class="row-vm">
<td>...</td>
<td>...</td>
...
</tr>
<tr class="row-details">
<td colspan="8">
<div class="vmdetail-left">
...
</div>
<div class="vmdetail-right">
...
</div>
</td>
</tr>
每隔一行包含第一行的详细数据。默认情况下,它是用 CSS 隐藏的,但我可以用 jQuery 将其滑动打开。
我想要实现的:类似于此 jQuery 插件的表排序: http://tablesorter .com/docs/
问题:插件应该将所有成对的行“粘合在一起”,并将它们移动在一起。应仅对第一行 (.row-vm
) 的数据进行排序,而忽略第二行 (.row-details
) 的内容。
有支持这个的 jQuery 插件吗?
Sorry for this title, I didn't know how to describe it better.
I have the following table:
<tr class="row-vm">
<td>...</td>
<td>...</td>
...
</tr>
<tr class="row-details">
<td colspan="8">
<div class="vmdetail-left">
...
</div>
<div class="vmdetail-right">
...
</div>
</td>
</tr>
Every second row contains detail data for the first row. By default, it is hidden with CSS, but I can slide it open with jQuery.
What I would like to achieve: Table sorting similar to this jQuery plugin: http://tablesorter.com/docs/
The problem: The plugin should "glue together" all pair rows, and move them together. The sorting should be done only with the data of the first row (.row-vm
), while ignoring the content of the second row (.row-details
).
Is there a jQuery plugin that supports this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在另一篇文章中发现了这个用于 jQuery 表排序器的小提琴,对我来说效果非常好!
I found this fiddle for the jQuery tablesorter in another post, worked beautifully for me!
Datatables.net 上提供的插件支持详细信息行,尽管我使用它们的方式是通过 ajax 打开详细信息行,而不是始终存在所有数据。但是,当您进行排序/重新排序时,详细信息仍保留在主要数据中。
The plugin available at Datatables.net supports detail rows, though the way I use them the detail rows are opened via ajax rather than all the data always being present. But when you do sort/reorder the details stay with the main data.
现在正在 2018 年寻找这个答案,如果您使用 mottie 的 tablesorter 2.0,文档中有一个名为“tablesorter-childRow”的类。所以上面的例子是:
Was looking for this answer now in 2018, and if you're using tablesorter 2.0 by mottie, there is a class in the documentation called "tablesorter-childRow". So the example above would be:
我知道这并不能回答您关于备用表排序器的实际问题,但我认为您可能会发现只需重新排列 HTML 并使用任何常规表排序器而不需要特殊要求即可获得更多成功。
也许您可以将可见行信息和“隐藏”数据放在同一行中,然后模拟它们位于不同行中的事实?
即:
您使用的表格元素越少越好。
I know this doesn't answer your actual question about an alternate tablesorter, but I think you might find more success just rearranging the HTML, and using any regular tablesorter without the need for special requirements.
Maybe you could put the visible row information, and the "hidden" data in the same row, and just emulate the fact that they are in different rows?
i.e.:
The less table elements you use, the better..
我有同样的问题,虽然我还没有编码,但我想如果我编写一个小部件,在排序后,循环遍历每个可见行,获取该行的伙伴,并将其移动到右侧放在桌子上,这可能会起作用。
I have the same problem, and although I've not coded it yet, I'm thinking that if I wrote a widget that after the sort, looped through each of the visible rows, got the row's partner, and moved it to the right place in the table, that might work.