如何对包含多个TBODY标签的表进行排序? [英] How to sort a table consisting of multiple TBODY tags?

查看:135
本文介绍了如何对包含多个TBODY标签的表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个表中有3个TBODY标记,其中包含3,4和5列.
如果单击说TBODY1上的任何列标题,是否所有TBODIES都可以排序.
我希望对整个表格进行排序,而不只是对一个特定的TBODY中的列进行排序.
我出于某种原因不得不在一个表中使用多个TBODY.有人可以指导我吗?

谢谢

Say there are 3 TBODY tags inside one single table containing 3,4 and 5 number of columns.
Is it possible for all the TBODIES to get sorted if any column header on say TBODY1 is clicked.
I want the whole table to get sorted , not just the columns in one particuular TBODY.
I had some reason for which I had to use multiple TBODY''s inside one single table. Can anyone guide me on this ?

Thanks

推荐答案

请参阅我对问题的评论.我的建议不可能是我从未做过的最终答案,只是想法.

我将使用诸如表排序器之类的源代码, http://tablesorter.com/docs/#Download [ ^ ]查看其工作原理.我希望它可能相对复杂但可以理解.

它可能无法在一组不同的tbody元素上运行(但请对其进行检查),但是您可以1)针对应用程序所需的数据量评估性能; 2)如果它不能以这种方式工作,请了解它是如何工作的,并编写一个修改后的组件来实现此功能.这个想法应该差不多.



这就是为什么我认为对库的修改应该不太难的原因:

元素<tbody>并不是一个很大的障碍,这是因为表在DOM树中是按行而不是按列排列的.

[END EDIT]

很抱歉,如果您发现实现起来太困难,但这是我个人目前可以想到的唯一方法.也许您可以找到其他更接近您需求的东西.

—SA
Please see my comment to the question. My advice cannot be a final answer as I never did it, just the idea.

I would take a source code of something like a table sorter, http://tablesorter.com/docs/#Download[^] to see how it works. It could be relatively complex but comprehensible, I hope.

It may not work across a set of different tbody elements (check it up though), but you could 1) evaluate performance for the volumes of data your applications require; 2) if it cannot work this way, understand how it works and write a modified component implementing this feature. The idea should be pretty much the same.



This is why I think that the library modification should be not too hard:

The element <tbody> is not a huge barrier, and this is because table is arranged in a DOM tree by rows, not by columns.

[END EDIT]

Sorry if you find it too difficult to achieve, but this is the only way I personally can think of at the moment. Maybe you could find something else closer to your needs.

—SA


我修改了sorttable.js库(版本2)以完成对多个表进行排序的任务,这些表是按设计分离但彼此相关的我已经对第一个表应用了排序,对另外两个表进行了相应的排序.
I have modified the sorttable.js library (version 2) to accomplish my task of sorting multiple tables that are separated by design but related to each other.I have applied the sorting for the first table and other two tables get sorted accordingly.


这篇关于如何对包含多个TBODY标签的表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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