javascript-jquery-tablesorter的问题:如果表头是多行的,点击排序好像就不正确了

表头里使用了colspan/rowspan后,就不灵了——有人在bbs.jquery.org.cn问了半年,也不见答案 

http://bbs.jquery.org.cn/read.php?tid-2318-fpage-11.html

看tablesorter自己的介绍,说是支持的:http://tablesorter.com/docs/  (下面红底部分)
Introduction
tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. It has many useful features including:

Multi-column sorting
Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
Support for ROWSPAN and COLSPAN on TH elements
Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)
Extensibility via widget system
Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+
Small code size
  

 

仔细看看,好像是列号的判断出了问题:多行跨列时,这个插件还是按从上到下、从左到右地遍历表头里的th,按遇到的顺序设置列号


|c1|c2   |c3      |c4|
|  |--+--+--+--+--|  |
|  |c5|c6|c7|c8|c9|  |

以上面的表头为例,其实只有7列;c8对应的实际上是第5列,但是tablesorter以为它是第8列!

现在th有一个属性设置的机会:<th ... class="{sorter:'text'}">用于指示该列的排序比较模式(按文本还是数值还是日期。。。。来比较该列的内容),不知道能不能扩展为:<th ... class="{sorter:'text'; truecolumn:'5'}">来指示点击该列表头,实际上将按第5列的内容来排序。。。。。。。。

 

这样就需要改写jquery.tablesorter.js文件。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值