1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
for (var i=0,L=bodies.length; i<L; i++) {
var tb = bodies[i], tbrows = tb.rows, rows = [];
//for(i=0; i < tbrows.length;i++)alert(tbrows[i].innerHTML);
// Allow tbodies to request that they not be sorted
if(!hasClass(tb,table.NoSortClassName)) {
// Create a separate array which will store the converted values and refs to the
// actual rows. This is the array that will be sorted.
var cRow, cRowIndex = 0;
if (cRow = tbrows[cRowIndex]){
// Funky loop style because it's considerably faster in IE
do {
if (rowCells = cRow.cells) {
var cellValue = (col<rowCells.length)?this.getCellValue(rowCells[col],useinnertext):null;
if (sortconvert) cellValue = sortconvert(cellValue);
rows[cRowIndex] = [cellValue,tbrows[cRowIndex]];
i++;
}
} while (cRow=tbrows[++cRowIndex])
}
// Do the actual sorting
rows.sort(newSortFunc);
//for(i=0; i<rows.length;i++) alert(rows[i]);
// Move the rows to the correctly sorted order. Appending an existing DOM object just moves it!
cRowIndex=0;
var displayedCount=0;
var f=[removeClass,addClass];
if (cRow=rows[cRowIndex]){
do {
tb.appendChild(cRow[1]);
} while (cRow=rows[++cRowIndex])
}
}
} |