headingClicked: function(e) ...{
var that = sorting.that;
// 被点击的目标链接
var linkEl = getEventTarget(e);
// 直接获取td, tr, thead 和 table
var td = linkEl.parentNode;
var tr = td.parentNode;
var thead = tr.parentNode;
var table = thead.parentNode;
// 获得目标链接的columnId属性
var column = linkEl.getAttribute('columnId') || td.cellIndex;
// 找出当前列的排序方向
var arrows = css.getElementsByClass(td, 'tableSortArrow', 'span');
var previousSortOrder = '';
if (arrows.length > 0) ...{
previousSortOrder = arrows[0].getAttribute('sortOrder');
}
that.lastSortedTable = table.id;
// 将哪一列被排序回馈给用户
// 首先把所有的排序方向复位
var arrows = css.getElementsByClass(tr, 'tableSortArrow', 'span');
for (var j = 0; j < arrows.length; j++) ...{
var arrowParent = arrows[j].parentNode;
arrowParent.removeChild(arrows[j]);
if (arrowParent != td) ...{
spanEl = createElement('span');
spanEl.className = 'tableSortArrow';
// 加入两个空格
// spanEl.appendChild(document.createTextNode(' '));
arrowParent.appendChild(spanEl);
}
}
// 现在,回馈给用户
var spanEl = createElement('span');
spanEl.className = 'tableSortArrow';
if (null == previousSortOrder || '' == previousSortOrder || 'DESC' == previousSortOrder) ...{
spanEl.appendChild(document.createTextNode(' ↑'));
td.setAttribute('sortOrder', 'ASC');
spanEl.setAttribute('sortOrder', 'ASC');
} else ...{
spanEl.appendChild(document.createTextNode(' ↓'));
td.setAttribute('sortOrder', 'DESC');
spanEl.setAttribute('sortOrder', 'DESC');
}
td.appendChild(spanEl);
// 以下为没有doPostBack的版本,已经取消
/**//*
if(td.firstChild.getAttribute('columnId')!=null) {
window.location = "?sortdirect="+td.getAttribute('sortOrder')+"&colid="+td.firstChild.getAttribute('columnId');
}
else {
window.location = "?sortdirect="+td.getAttribute('sortOrder')+"&colid="+td.getAttribute('columnId');
}
*/
// 使用__doPostBack进入后台处理
__doPostBack('Pars',"sortdirect="+td.getAttribute('sortOrder')+"&colid="+td.firstChild.getAttribute('columnId'));
return false;
},
/**//**
* 隔行换色
**/
doStripe : function(rowItem) ...{
if (!this.isOdd) ...{
css.addClassToElement(rowItem, 'odd');
} else ...{
css.removeClassFromElement(rowItem, 'odd');
}
this.isOdd = !this.isOdd;
}
}
function sortInit() ...{
sorting.init();
}
addEvent(window, 'load', sortInit)
后台:
public DataView SortBuilde