WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Improved SID Grid Sorting, Martijn Hooimeijer, October 1, 2003
     Re:Improved SID Grid Sorting, Erik Arvidsson, October 1, 2003
     Re:Improved SID Grid Sorting, Martijn Hooimeijer, October 1, 2003

Subject: Improved SID Grid Sorting From: Martijn Hooimeijer Date: October 1, 2003

Hi.

I first of all Cudos to Erik for these out-of-this-world packages!

When testing the grid package (grid10) I noticed that sorting on ID did not give the desired result. The sorting produced: 1, 10, 11, .. 19, 2, 20, ...

I changed the code in grid.js as follows (making sure the SID is converted to a number prior to comparison, if it can be converted to a number that is)

function compareBySid(d) {

return function (n1, n2) {

if (n1.sid == null) { return +1; }

if (n2.sid == null) { return -1; }

if (isNan(parseFloat(n1.sid)) || isNan(parseFloat(n2.sid))){

if (n1.sid < n2.sid) { return (d) ? -1 : +1; }

if (n1.sid > n2.sid) { return (d) ? +1 : -1; }

}else{

if (new Number(n1.sid) < new Number(n2.sid)) { return (d) ? -1 : +1; }

if (new Number(n1.sid) > new Number(n2.sid)) { return (d) ? +1 : -1; }

}

return 0;

};

}




Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX