定单管理上 JS表格排序第1/2页
自己经常用的比较好用的效果 经常用在定单管理上 JS表格排序 不需要用ASP再计算一次
var dom = (document.getElementsByTagName) ? true : false;
var ie5 = (document.getElementsByTagName && document.all) ? true : false;
var arrowUp, arrowDown;
if (ie5 || dom)
initSortTable();
function initSortTable() {
arrowUp = document.createElement("SPAN");
var tn = document.createTextNode("↓");
arrowUp.appendChild(tn);
arrowUp.className = "arrow";
arrowDown = document.createElement("SPAN");
var tn = document.createTextNode("↑");
arrowDown.appendChild(tn);
arrowDown.className = "arrow";
}
function sortTable(tableNode, nCol, bDesc, sType) {
var tBody = tableNode.tBodies[0];
var trs = tBody.rows;
var a = new Array();
for (var i=0; i fTypeCast(getInnerText(n2.cells[c])))
return d ? +1 : -1;
return 0;
};
}
function sortColumn(e) {
var tmp, el, tHeadParent;
if (ie5)
tmp = e.srcElement;
else if (dom)
tmp = e.target;
tHeadParent = getParent(tmp, "THEAD");
el = getParent(tmp, "TD");
if (tHeadParent == null)
return;
if (el != null) {
var p = el.parentNode;
var i;
if (el._descending) // catch the null
el._descending = false;
else
el._descending = true;
if (tHeadParent.arrow != null) {
if (tHeadParent.arrow.parentNode != el) {
tHeadParent.arrow.parentNode._descending = null;
}
tHeadParent.arrow.parentNode.removeChild(tHeadParent.arrow);
}
if (el._descending)
tHeadParent.arrow = arrowDown.cloneNode(true);
else
tHeadParent.arrow = arrowUp.cloneNode(true);
el.appendChild(tHeadParent.arrow);
// get the index of the td
for (i=0; i
序号 | 名称 | 金额 | 数量 | 日期 | 点击 |
1 | a | 1.26 | 5 | 2006-1-5 | 321 |
2 | e | 12.65 | 6 | 2006-10-4 | 456 |
3 | f | 21.03 | 4 | 2006-2-7 | 122 |
4 | g | 21.33 | 3 | 2006-8-9 | 147 |
5 | h | 12.21 | 5 | 2007-8-1 | 1024 |
6 | d | 14.36 | 2 | 2003-4-9 | 99 |
7 | a | 25.3 | 3 | 2006-10-4 | 122 |
8 | wd | 0.35 | 44 | 2008-10-25 | 444 |
9 | f | 12.1 | 56 | 2006-10-23 | 123 |
10 | w | 123.3 | 12 | 2005-5-7 | 321 |
11 | e | 654 | 12 | 2006-9-12 | 99 |
12 | t | 12.21 | 13 | 2007-7-3 | 100 |
13 | f | 12.64 | 14 | 2001-12-31 | 32 |
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
当前1/2页 12下一页阅读全文