javascript 表格排序和表头浮动效果(扩展SortTable)
更新时间:2009年04月07日 23:09:48 作者:
前段时间一个项目有大量页面用到表格排序和表头浮动的效果,在网上找了几个表格排序的js代码,最后选择了 Stuart Langridge的SortTable,在SortTable基础上做了些扩展,加上了表头浮动效果及一些小功能。
一、SortTable说明
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src=”sorttable.js”></script> to your HTML
Add class=”sortable” to any table you'd like to make sortable
Click on the headers to sort
Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it.
用法:将要排序的表格添加CSS,如<table class=”sortable”>
默认对所有列都会添加排序功能,对于不需要排序的列可添加CSS:”sorttable_nosort”,如<td class=”sorttable_nosort”></td>
二、更新说明
Update:
version 2.1
9th Mar 2009
Hopesoft , http://www.51ajax.com/blog/
说明:
1.增加中文排序
2.增加指定各行使用不同css样式功能(比如奇偶行背景色不一致)
用法:在要表头浮动的表格上添加属性,如<table class="sortable" rowclass="bg1,bg2,bg3">
3.增加表头浮动功能(支持同一个页面有多个表格,比如不同Tab标签下的各个表格)
用法:在要表头浮动的表格上添加CSS,如<table class="scrolltable">
另外最好指定“表头”和“数据行”的各列的列宽,如
<tr><td class='w1'>姓名</td><td class='w2'>年龄</td></tr>
<tr><td class='w1'>张三</td><td class='w2'>21</td></tr>
以避免在FireFox下表头浮动时表头各列与数据各列不对齐
4.增加页面载入后自动排序
用法:在表格上添加属性autosortcol,对应要自动排序的列号,注意是从0开始
如<table class="sortable" autosortcol="3">,则表示当页面载入成功后,会自动对第4行进行
新增的代码都用中文做了注释,屏蔽了原有代码中部分代码。另外原来代码中升降序顺序ms是反的,我这边做了更改。
演示地址 http://img.jb51.net/online/sorttable/sorttable.htm
打包下载地址: http://img.jb51.net/online/sorttable/sorttable.rar
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src=”sorttable.js”></script> to your HTML
Add class=”sortable” to any table you'd like to make sortable
Click on the headers to sort
Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it.
用法:将要排序的表格添加CSS,如<table class=”sortable”>
默认对所有列都会添加排序功能,对于不需要排序的列可添加CSS:”sorttable_nosort”,如<td class=”sorttable_nosort”></td>
二、更新说明
Update:
version 2.1
9th Mar 2009
Hopesoft , http://www.51ajax.com/blog/
说明:
1.增加中文排序
2.增加指定各行使用不同css样式功能(比如奇偶行背景色不一致)
用法:在要表头浮动的表格上添加属性,如<table class="sortable" rowclass="bg1,bg2,bg3">
3.增加表头浮动功能(支持同一个页面有多个表格,比如不同Tab标签下的各个表格)
用法:在要表头浮动的表格上添加CSS,如<table class="scrolltable">
另外最好指定“表头”和“数据行”的各列的列宽,如
<tr><td class='w1'>姓名</td><td class='w2'>年龄</td></tr>
<tr><td class='w1'>张三</td><td class='w2'>21</td></tr>
以避免在FireFox下表头浮动时表头各列与数据各列不对齐
4.增加页面载入后自动排序
用法:在表格上添加属性autosortcol,对应要自动排序的列号,注意是从0开始
如<table class="sortable" autosortcol="3">,则表示当页面载入成功后,会自动对第4行进行
新增的代码都用中文做了注释,屏蔽了原有代码中部分代码。另外原来代码中升降序顺序ms是反的,我这边做了更改。
演示地址 http://img.jb51.net/online/sorttable/sorttable.htm
打包下载地址: http://img.jb51.net/online/sorttable/sorttable.rar
相关文章
Java中int与integer的区别(基本数据类型与引用数据类型)
这篇文章主要介绍了int与integer的区别(基本数据类型与引用数据类型),简单的说 int 是基本数据类型,integer 是引用数据类型,具体区别详解大家参考下本文2017-02-02
JavaScript 进度条实现代码(Firefox等相似浏览器下不支持)
JavaScript实现的进度条,可惜在Firefox等相似浏览器下不支持(远程)2009-07-07
解决window.opener=null;window.close(),只支持IE6不支持IE7,IE8的问题
本篇文章主要是对window.opener=null;window.close(),只支持IE6不支持IE7,IE8的解决方法进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助2014-01-01
JavaScript中setInterval()用法举例详解
这篇文章主要给大家介绍了关于JavaScript中setInterval()用法的相关资料,setInterval()方法可按照指定的周期(以毫秒计)来调用函数或计算表达式,文中通过代码示例介绍的非常详细,需要的朋友可以参考下2023-10-10


最新评论