Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/11/2005, 13:55
Avatar de Dorita
Dorita
 
Fecha de Ingreso: junio-2005
Ubicación: Entre la silla y el escritorio
Mensajes: 97
Antigüedad: 18 años, 11 meses
Puntos: 0
Reformulo mi pregunta: ya implementé el sistema de ordenamiento de la FAQ #101, pero no me funciona...si presiono el link de la columna fecha por ejemplo, se desaparecen todos los registros q estaba listados anteriormente y me muestra toda la página pero sin los registros... aqui les pongo el codigo q tengo:

esto en el head de mi página:
Código PHP:
<Script language="javascript" type="text/javascript">        
<!-- 
Begin
function compare(sVal1sVal2){  // para cambiar el orden (ascendente o descendente) se debe cambiar a negativo el primer 1 y a positivo el segundo, segun convenga
if (sVal1 sVal2) return 1;
if (
sVal1 sVal2) return -1;
return 
0;



function 
setDataType(cValue)  // Esta función convierte fechas y numeros para el array apropiado clasificando en la función sort.
  
{
    var 
isDate = new Date(cValue);
    if (
isDate == "NaN")
      {
        if (
isNaN(cValue)) //El valor es un string, pone todos los caracteres en upper case(mayúsculas) para asegurar un correcto
                            // ordenamiento de la a - z.
          
{
            
cValue cValue.toUpperCase();
            return 
cValue;
          }
        else 
// si el valor es un numero, para prevenir el ordenamiento string de un numero se le agrega un dígito adicional q es 
                // la suma del largo del numero cuando es un string.
          
{
            var 
myNum;
            
myNum String.fromCharCode(48 cValue.length) + cValue;
            return 
myNum;
          }
        }
  else
      {
          
// si el valor a ordenar es una fecha, remueve toda la puntuación y retorna un numero string
        //BUG - STRING AND NOT NUMERICAL SORT .....
        // ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5  etc.)
        
var myDate = new String();
        
myDate isDate.getFullYear() + " " ;
        
myDate myDate isDate.getMonth() + " ";
        
myDate myDate isDate.getDate(); + " ";
        
myDate myDate isDate.getHours(); + " ";
        
myDate myDate isDate.getMinutes(); + " ";
        
myDate myDate isDate.getSeconds();
        
//myDate = String.fromCharCode(48 + myDate.length) + myDate;
        
return myDate ;
      }
  } 



function 
sortTable(coltableToSort)
  {
    var 
iCurCell col tableToSort.cols;
    var 
totalRows tableToSort.rows.length;
    var 
bSort 0;
    var 
colArray = new Array();
    var 
oldIndex = new Array();
    var 
indexArray = new Array();
    var 
bArray = new Array();
    var 
newRow;
    var 
newCell;
    var 
i;
    var 
c;
    var 
j;
    
// ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
    
for (i=1tableToSort.rows.lengthi++)
      {
        
colArray[1] = setDataType(tableToSort.cells(iCurCell).innerText);
        
iCurCell iCurCell tableToSort.cols;
      }
    
// ** COPY ARRAY FOR COMPARISON AFTER SORT
    
for (i=0colArray.lengthi++)
      {
        
bArray[i] = colArray[i];
      }
    
// ** SORT THE COLUMN ITEMS
    //alert ( colArray );
    
colArray.sort(compare);
    
//alert ( colArray );
    
for (i=0colArray.lengthi++)
      { 
// LOOP THROUGH THE NEW SORTED ARRAY
        
indexArray[i] = (i+1);
        for(
j=0bArray.lengthj++)
          { 
// LOOP THROUGH THE OLD ARRAY
            
if (colArray[i] == bArray[j])
              {  
// WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
                // CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
                // NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
                // MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
                // NEW ORDER ARRAY
                
for (c=0c<ic++)
                  {
                    if ( 
oldIndex[c] == (j+1) )
                    {
                      
bSort 1;
                    }
                      }
                      if (
bSort == 0)
                        {
                          
oldIndex[i] = (j+1);
                        }
                          
bSort 0;
                        }
          }
    }
  
// ** SORTING COMPLETE, ADD NEW ROWS TO BASE OF TABLE ....
  
for (i=0i<oldIndex.lengthi++)
    {
      
newRow tableToSort.insertRow();
      for (
c=0c<tableToSort.colsc++)
        {
          
newCell newRow.insertCell();
          
newCell.innerHTML tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
        }
      }
  
//MOVE NEW ROWS TO TOP OF TABLE ....
  
for (i=1i<totalRowsi++)
    {
      
tableToSort.moveRow((tableToSort.rows.length -1),1);
    }
  
//DELETE THE OLD ROWS FROM THE BOTTOM OF THE TABLE ....
  
for (i=1i<totalRowsi++)
    {
      
tableToSort.deleteRow();
    }
  }
//  End -->

</Script> 
y en la tabla:

Código HTML:
<table name="rsTable" id="rsTable" border="1" align="center">
	<tr>
	<th width="16%" height="36" scope="col"><span class="estiloTablas">Id Grabaci&oacute;n</span></th>
	<th width="6%" scope="col"><span class="estiloTablas">Id Ejecutivo</span></th>
	<th width="13%" scope="col"><span class="estiloTablas"><a href="javascript:sortTable(0, rsTable);">Fecha grabaci&oacute;n</a></span><br></th>
</table>
alguna ayuda????   :'( 


salu2.-:adios: 
__________________

<nick>Dorita</nick>...si lo sé, soy una ñoña ;)