Foros del Web » Programando para Internet » Javascript » Frameworks JS »

seleccionar filas con la tecla SHIFT + tecla hacia abajo

Estas en el tema de seleccionar filas con la tecla SHIFT + tecla hacia abajo en el foro de Frameworks JS en Foros del Web. hola a todos estoy trabajando en un ejemplo echo con jquery en el cual seleccionas filas(en realidad no la seleccionas solo se le cambia el ...
  #1 (permalink)  
Antiguo 19/01/2011, 09:25
 
Fecha de Ingreso: diciembre-2010
Mensajes: 10
Antigüedad: 13 años, 3 meses
Puntos: 1
Pregunta seleccionar filas con la tecla SHIFT + tecla hacia abajo

hola a todos estoy trabajando en un ejemplo echo con jquery en el cual seleccionas filas(en realidad no la seleccionas solo se le cambia el "color") de una tabla(tablaBBDD) al hacer clic sobre ellas y al darle a un boton las pasa a otra tabla(guardarRegistros) hasta ahi todo va bien, el problema es que quiero simular el evento de windows que cuando precionas SHIFT + la tecla hacia abajo va seleccionando varias filas hasta que el usuario suelta las teclas, esto es por que cuando mi tabla trae 500 registros o mas tedioso ir haciendo clic en cada fila.



Como no he podido simular este efecto trate de hacer otro donde al mantener precionado el boton de el mouse y moverlo hacia abajo seleccionara las filas(cambiara el color) hasta que el usuario suelte el boton cosa que tampoco he podido terminar si me pudieran ayudar se los agradeceria mucho

este es el codigo, si cambia de color las filas pero tengo que pasar el puntero siempre por la primera fila coloreada

gracias

Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2.   <head>
  3.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4.     <style>
  5.     <!--
  6.       .fila{
  7.      
  8.       }
  9.       .seleccionado{
  10.          background: rgb(255,134,0);
  11.       }
  12.    //-->
  13.     </style>
  14.     <script src="jquery-1.3.2.min.js"></script>
  15.     <script>
  16.       $(function(){          
  17.           $("table.tablaBBDD tr").each(function(){
  18.            
  19.             $(this).mousedown(function(){
  20.                 $nextTR = $(this).next('tr');
  21.                 $nextTR.hover(function(){  
  22.                 $nextTR.removeClass('fila');
  23.                 $nextTR.addClass('seleccionado');
  24.                 $nextTR = $nextTR.next('tr');
  25.                 })
  26.             })
  27.           });
  28.            $("table.guardarRegistros tr").each(function(){
  29.             $(this).click(function(){
  30.               if($(this).attr("class") == 'fila'){
  31.                 $(this).removeClass('fila');
  32.                 $(this).addClass('seleccionado');  
  33.               }else{
  34.                 $(this).removeClass('seleccionado');
  35.                 $(this).addClass('fila');
  36.               }  
  37.             })
  38.           });
  39.          $("#pasar").click(function(){
  40.             $("table.tablaBBDD tr").each(function(){
  41.                if($(this).attr("class") == 'seleccionado'){
  42.                   $("#guardarRegistros").append($(this));
  43.                   $(this).removeClass('seleccionado');
  44.                }
  45.             })
  46.          })
  47.           $("#regresar").click(function(){
  48.             $("table.guardarRegistros tr").each(function(){
  49.                if($(this).attr("class") == 'seleccionado'){
  50.                   $("#tablaBBDD").append($(this));
  51.                   $(this).removeClass('seleccionado');
  52.                }
  53.             })
  54.          })
  55.                        
  56.       })
  57.     </script>
  58.        
  59.   </head>
  60.  
  61.   <body>
  62.   <table>
  63.   <tr>
  64.   <td>
  65.     <!-- TABLA QUE PROVIENE DE LA BASE  DE DATOS -->
  66.     <table width="500" class="tablaBBDD" id="tablaBBDD">
  67.      <tr class="fila">
  68.       <td> Registro 1</td>
  69.       <td> Registro 1</td>
  70.       <td> Registro 1</td>
  71.       <td> Registro 1</td>
  72.       <td> Registro 1</td>
  73.      </tr>
  74.      
  75.      <tr class="fila">
  76.       <td> Registro 2</td>
  77.       <td> Registro 2</td>
  78.       <td> Registro 2</td>
  79.       <td> Registro 2</td>
  80.       <td> Registro 2</td>
  81.      </tr>
  82.      
  83.      <tr class="fila">
  84.       <td> Registro 3</td>
  85.       <td> Registro 3</td>
  86.       <td> Registro 3</td>
  87.       <td> Registro 3</td>
  88.       <td> Registro 3</td>
  89.      </tr>
  90.      
  91.      <tr class="fila">
  92.       <td> Registro 4</td>
  93.       <td> Registro 4</td>
  94.       <td> Registro 4</td>
  95.       <td> Registro 4</td>
  96.       <td> Registro 4</td>
  97.      </tr>
  98.     </table>
  99.     </td>
  100.     <td>
  101.     <!-- TABLA A LLENAR -->
  102.    
  103.     <input type="button" id="pasar" value="Pasar Datos">
  104.     <input type="button" id="regresar" value="Regresar Datos">
  105.     </td>
  106.     <td>
  107.     <table class="guardarRegistros" id="guardarRegistros">
  108.       <tr class="fila">
  109.       <td> Registro 5</td>
  110.       <td> Registro 5</td>
  111.       <td> Registro 5</td>
  112.       <td> Registro 5</td>
  113.       <td> Registro 5</td>
  114.       </tr>
  115.      
  116.     </table>
  117.      </td>
  118.      </tr>
  119.      </table>
  120.   </body>
  121.  
  122. </html>

Etiquetas: color, filas, jquery, seleccionar, cambios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:17.