Salut tout le monde,

Je vient de commener à travailler avec JS, j'ai trouvé une classe de tri des tableau js (javascripttoolbox)

http://www.javascripttoolbox.com/lib/table/index.php

pour faire le tri sans recharger la page, ca marche tres bien... sauf qu'avec bcp de données ca devient super lent

J'ai essayé de regarder le code pour améliorer le fonctionnement mais je trouve des bouts de code que je comprends pas.

déja la boucle qui ralentit le traitement est :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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])
				}
			}
		}
précisemment je comprends pas les 2 lignes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
var cRow, cRowIndex = 0; 
				if (cRow = tbrows[cRowIndex]){...
Je vois pas comment la variable cRow est reconnue sans être initialisé?! aussi je comprends pas le if qui marche sans le double-égal (==) et ca bloque si je le mets.

Si qlq un a une idée, j en serai reconnaissante (c'est urgent)