Javascript排序非线性表 [英] Javascript sort non-linear table

查看:30
本文介绍了Javascript排序非线性表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的桌子:

<头><tr class="trheader"><th colspan="2">111</th><th>-SORT-ME-</th>第 222 个第 333 个</tr></thead><tr><td id="id_1"><img src=""></td><td id="id_11">11</td><td id="id_12">===SORT.VALUE===</td><td id="id_13">13</td><td id="id_14"><a href="#" class="send_data"><img src=""></a></td></tr><tr><td id="id_t1" colspan="5" onclick="some_func"><label for="id_i1">_lbl_</label><img id="image_1" src=""></img><div id="id_i1">

</td></tr><tr><td id="id_2"><img src=""></td><td id="id_21">21</td><td id="id_22">===SORT.VALUE===</td><td id="id_23"></td><td id="id_ordbtn_2"><a href="#"><img src=""></a></td></tr><tr><td id="id_t2" colspan="5" onclick="some_func"><label for="id_i2">_label2_</label><img id="image_2" src=""><div id="id_i2">

</td></tr>...更多相同...</tbody>

是否可以使用 JQuery tablesorter 或其他脚本根据 -SORT-ME- 中的值对表进行排序//===SORT.VALUE===//===SORT.VALUE=== 和为了保持表格正确显示,因为我尝试使用 tablesort(er) 并且它弄乱了它(开始做切换行...显示表格损坏)这是因为第二个 :: colspan=5 数据,这使得表格非统一或非标准,或者我不知道确切的短语,我希望你明白我想说的.

抱歉,您对问题的描述不是很丰富,但正如您已经猜到英语不是我的母语,当我需要解释更复杂的事情时,我会很挣扎.

谢谢你们,非常感谢你们的帮助.

解决方案

您是否尝试添加与父行一起排序的子行?

如果是这样,我发现这个演示就是这样做的.它实际上是 tablesorter 插件 v2.0.5 的一部分,但没有记录.所以你可以复制他们使用的html和代码,但你不需要下载mod.

我添加了缺失的文档 在我发表的一篇博客文章中,我在 github 上分叉并修改了插件本身,并且如果您有兴趣,还制作了另一个 子行演示.>

I have table like that :

<table id="table_id" class="tablesorter">
<thead>
<tr class="trheader">
<th colspan="2">111</th>
<th>-SORT-ME-</th>
<th>222</th>
<th>333</th>
</tr>
</thead>

<tbody>
<tr>
<td id="id_1"><img src=""></td>
<td id="id_11">11</td>
<td id="id_12">===SORT.VALUE===</td>
<td id="id_13">13</td>
<td id="id_14"><a href="#" class="send_data"><img src=""></a></td>
</tr>
<tr>
<td id="id_t1" colspan="5" onclick="some_func">
<label for="id_i1">_lbl_</label>
<img id="image_1" src=""></img>
<div id="id_i1">
</div>
</td>
</tr>

<tr>
<td id="id_2"><img src=""></td>
<td id="id_21">21</td>
<td id="id_22">===SORT.VALUE===</td>
<td id="id_23"></td>
<td id="id_ordbtn_2"><a href="#"><img src=""></a></td>
</tr>
<tr>
<td id="id_t2" colspan="5" onclick="some_func">
<label for="id_i2">_label2_</label>
<img id="image_2" src="">
<div id="id_i2">
</div>
</td>
</tr>
... more of the same...
</tbody>
</table>

Is it somehow possible to use JQuery tablesorter or other script to sort the table based on values in -SORT-ME- // ===SORT.VALUE=== // ===SORT.VALUE=== and to keep the table displayed properly, as i tried to use tablesort(er) and it messes it ( start do switch rows... displays the table broken ) It's because of the second :: colspan=5 data, that makes the table non uniform or non-standard or i don't know the exact phrase for that, i hope you get what i'm trying to say.

Sorry for the not very informative description of the problem, but as you've already guessed English is not my native language and i struggle when i need to explain more complicated things.

Thank you guys, your help is greatly appreciated.

解决方案

Are you trying to add a child row that gets sorted along with the parent row?

If so, I found this demo on doing just that. It is actually part of the tablesorter plugin v2.0.5 but it isn't documented. So you can just copy the html and code they use, but you don't need to download the mod.

I've added the missing documentation in a blog post I made and I've forked and modified the plugin itself on github and made another child row demo, if you are interested.

这篇关于Javascript排序非线性表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆