Foros del Web » Programando para Internet » Jquery »

Datatables, no funciona el paginador

Estas en el tema de Datatables, no funciona el paginador en el foro de Jquery en Foros del Web. Hola amigos del foro. Estoy trabajando con datatables, resulta que tengo un calendario donde elijo una fecha para filtrar los resultados, y funciona correctamente, pero ...
  #1 (permalink)  
Antiguo 30/07/2014, 14:22
 
Fecha de Ingreso: febrero-2011
Mensajes: 195
Antigüedad: 13 años, 2 meses
Puntos: 1
Datatables, no funciona el paginador

Hola amigos del foro.

Estoy trabajando con datatables, resulta que tengo un calendario donde elijo una fecha para filtrar los resultados, y funciona correctamente, pero por ejemplo, si tengo el paginador y le doy clic a algun numero de este para ver mas registros me hace la funcion como si seleccionara una fecha del calendario cuando estoy seleccionando un numero del paginador.

Alguien me podria echar una mano?
  #2 (permalink)  
Antiguo 31/07/2014, 09:43
Avatar de fhederico  
Fecha de Ingreso: agosto-2009
Mensajes: 247
Antigüedad: 14 años, 8 meses
Puntos: 23
Respuesta: Datatables, no funciona el paginador

Hola,

Podrias poner el codigo? ya que es un poco dificil ayudarte si no se ve ningun codigo :D
__________________
Si encuentras que tu pregunta fue respondida, se agradeceria enormemente que la marcaras como solucionada... si... es el boton verde gigante que esta al final de la pagina :)
  #3 (permalink)  
Antiguo 31/07/2014, 10:26
 
Fecha de Ingreso: febrero-2011
Mensajes: 195
Antigüedad: 13 años, 2 meses
Puntos: 1
Respuesta: Datatables, no funciona el paginador

Este es el codigo


Código PHP:
$(document).ready(function(){
    $.
datepicker.regional['es'] = {
        
closeText'Cerrar',
        
prevText'<Ant',
        
nextText'Sig>',
        
currentText'Hoy',
        
monthNames: ['Enero''Febrero''Marzo''Abril''Mayo''Junio''Julio''Agosto''Septiembre''Octubre''Noviembre''Diciembre'],
        
monthNamesShort: ['Ene','Feb','Mar','Abr''May','Jun','Jul','Ago','Sep''Oct','Nov','Dic'],
        
dayNames: ['Domingo''Lunes''Martes''Miércoles''Jueves''Viernes''Sábado'],
        
dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
        
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
        
weekHeader'Sm',
        
dateFormat'yy-mm-dd',
        
firstDay1,
        
isRTLfalse,
        
showMonthAfterYearfalse,
        
yearSuffix''
    
} ;
    
    $.
datepicker.setDefaults($.datepicker.regional['es']);

    var 
oTable = $('#example').dataTable( {
        
"sPaginationType""full_numbers",
        
"bProcessing"true,
        
"bServerSide"true,
        
"sAjaxSource""server_processing.php",
        
              
               
        
"fnServerParams": function ( aoDatafnCallback ) {
                         
//Cuando doy clic esta codigo hace el filtro de las fechas, lo que estaba pensando
                         //era algo asi como nadamas ejecutar esto cuando se diera clic en el calendario
            
aoData.push( { "name""datepicker_min2""value": $("#datepickercalendario").val() } );
            
aoData.push( { "name""datepicker_max2""value": $("#datepickercalendario").val() } );
        },

$( 
"#datepickercalendario" ).datepicker ( {
        
dateFormat'yy-mm-dd',
        
numberOfMonths1,
        
"onSelect": function(date) {
            
min = new Date(date).getTime();
            
max = new Date(date).getTime();
            
oTable.fnDraw();
        }
    }) 
  #4 (permalink)  
Antiguo 31/07/2014, 17:41
Avatar de fhederico  
Fecha de Ingreso: agosto-2009
Mensajes: 247
Antigüedad: 14 años, 8 meses
Puntos: 23
Respuesta: Datatables, no funciona el paginador

Estimado,

Necesito tambien tu codigo HTML, ya que es tu desarrollo y por lo tanto yo no tengo idea de lo que tienes y sobre todo de como se va cargando, asi que la unica manera que tengo es intentar copiar tu codigo y reproducirlo en mi local, para poder debugear y encontrar el problema, asi que mientras mas informacion agreges mas facil me es poder ayudarte y reproducir este error.

Por cierto, asumo que tu archivo "server_processing.php", contiene una query que lo unico que hace es retornar recibir algun parametro, procesar esta busqueda y retornar el resultado, o no?

Saludos
__________________
Si encuentras que tu pregunta fue respondida, se agradeceria enormemente que la marcaras como solucionada... si... es el boton verde gigante que esta al final de la pagina :)
  #5 (permalink)  
Antiguo 01/08/2014, 07:04
 
Fecha de Ingreso: febrero-2011
Mensajes: 195
Antigüedad: 13 años, 2 meses
Puntos: 1
Respuesta: Datatables, no funciona el paginador

Hola, efectivamente, lo que hace el server_processing es que cuando recibe las fechas hace el filtro, este es el codigo completo

Código PHP:

<!DOCTYPE html>

<
head>

<
link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">

<
script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

        <link rel="stylesheet" href="css/bootstrap.min.css">
        <!-- Latest compiled and minified JavaScript -->
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
        <style>
    
        </style>
        <link rel="stylesheet" href="css/calendar-ipad/jquery-ui-1.10.3.custom.min.css">
        <link rel="stylesheet" href="css/calendar-ipad/jquery-ui-1.10.3.custom.css">
    

        <script src="js/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    
    <!-- ptTimeSelect files below -->
    <link rel="stylesheet" type="text/css" href="http://pttimeselect.sourceforge.net/src/jquery.ptTimeSelect.css" media="screen" />
    <script type="text/javascript" language="JavaScript" src="http://pttimeselect.sourceforge.net/src/jquery.ptTimeSelect.js"></script>

<style>
div.dataTables_length {
    float: left;
    font-family: "Trebuchet MS", Arial;
    background-color: #963;
    margin-top:10px;
}

div.dataTables_filter {
    float: right;
    background-color: #963;
    display:none;
}

div.dataTables_info {
    float: left;
    background-color: #963;
    font-family: "Trebuchet MS", Arial;
    font-size:12px;
    margin-top:10px;
    margin-bottom:5px;
}

div.dataTables_paginate {
    float: right;
    background-color: #963;
    font-family: "Trebuchet MS", Arial;
    font-size:12px;
    margin-top:10px;
    margin-bottom:5px;
}

div.dataTables_length,
div.dataTables_filter,
div.dataTables_paginate,
div.dataTables_info {
    padding: 6px;
}

table.pretty {
    clear: both;
}

/* Self clearing - */
div.dataTables_wrapper:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

html[xmlns] .dataTables_wrapper { display: block; }

* html .dataTables_wrapper { height: 1%; }

table.pretty {
    width: 100%;
    clear: both;
}

table.pretty td,
table.pretty th {
    padding: 10px;
    border: 1px solid #fff;
}

/* cabeceras */
table.pretty thead th {
    text-align: center;
    background: #747474;
    color:#FFF;
}

/* Body cells */
table.pretty tbody th {
    text-align: left;
    background: #91c5d4;
}

table.pretty tbody td {
    text-align: center;
    background: #963;
}

table.pretty tbody tr.odd td {
    background: #efefef;
}

/* Footer cells */ 
table.pretty tfoot th {
    background: #747474;
    text-align: center;
    color:#FFF;
}

table.pretty tfoot td {
    background: #d7e1c5;
    text-align: center;
    font-weight: bold;
}

div.dataTables_wrapper {
    background-color: #963;
}

table.pretty thead th.sorting_asc {
    background: #747474 url('images/sort_asc.png') no-repeat right center;
}

table.pretty thead th.sorting_desc {
    background: #747474 url('images/sort_desc.png') no-repeat right center;
}

table.pretty thead th.sorting {
    background: #747474 url('images/sort_both.png') no-repeat right center;
}

a.paginate_button,
a.paginate_active {
    display: inline-block;
    background-color: #efefef;
    padding: 2px 6px;
    margin-left: 2px;
    cursor: pointer;
    *cursor: hand;
}

a.paginate_active {
    background-color: transparent;
    border: 1px solid black;
}

a.paginate_button_disabled {
    color: #3d6672;
}

.paging_full_numbers a:active {
    outline: none
}

.paging_full_numbers a:hover {
    text-decoration: none;
}

div.dataTables_paginate span>a {
    width: 15px;
    text-align: center;
}

div.dataTables_info {
    padding: 9px 6px 6px 6px;
}

#ui-datepicker-div {
  z-index: 9999999!important;
}

.ui-datepicker {
    height: 225px ;
    padding:0 0.2em 0.2em 0;
    width: 350px;
}

</style>

<script type="text/javascript" src="js/jquery.dataTables.min2.js"></script>

<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
<!--script>$.noConflict();</script-->
<!--script src="js/vendor/bootstrap.min.js"></script-->

<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src='//www.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));

function fnFilterGlobal (){

    $('#example').dataTable().fnFilter(
        $("#global_filter").val(),null,
        $("#global_regex")[0].checked,
        $("#global_smart")[0].checked
    );
}

function fnFilterColumn ( i )
{
    $('#example').dataTable().fnFilter(
        $("#col"+(i+1)+"_filter").val(),i,
        $("#col"+(i+1)+"_regex")[0].checked,
        $("#col"+(i+1)+"_smart")[0].checked
    );
}


$(document).ready(function(){
    $.datepicker.regional['es'] = {
        closeText: 'Cerrar',
        prevText: '<Ant',
        nextText: 'Sig>',
        currentText: 'Hoy',
        monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
        monthNamesShort: ['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'],
        dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
        dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
        dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
        weekHeader: 'Sm',
        dateFormat: 'yy-mm-dd',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''
    } ;
    
    $.datepicker.setDefaults($.datepicker.regional['es']);

    var oTable = $('#example').dataTable( {
        "sPaginationType": "full_numbers",
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "server_processing.php",
    "fnServerParams": function ( aoData, fnCallback ) {
            aoData.push( { "name": "datepicker_min2", "value": $("#datepickercalendario").val() } );
            aoData.push( { "name": "datepicker_max2", "value": $("#datepickercalendario").val() } );
        },

        
        "aaSorting": [[ 0, "desc" ]],

        "aoColumns": [
            { "bVisible":    false },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    true },
            { "bVisible":    false },
            { "bVisible":    false }
        ],
        
        "oLanguage": {
            "sLengthMenu": "Mostrando _MENU_ eventos por página",
            "sZeroRecords": "No se encontro Nada - Disculpe",
            "sInfo": "Mostrando _START_ de _END_ de un total de _TOTAL_ eventos",
            "sInfoEmpty": "Mostrando 0 de 0 de un total de 0 eventos",
            "sInfoFiltered": "(filtrados de _MAX_ total de eventos)",
            "sSearch": "Buscar",
            "oPaginate": {
                "sFirst": " Primera ",
                "sLast": " Última ",
                "sNext": " Siguiente ",
                "sPrevious": " Anterior "
            }
        }
    });
    
    $( "#datepickercalendario" ).datepicker ( {
        dateFormat: 'yy-mm-dd',
        numberOfMonths: 1,
        "onSelect": function(date) {
            min = new Date(date).getTime();
            max = new Date(date).getTime();
            oTable.fnDraw();
            alert("Solamente aqui debe de hacer el filtro");
        }
    })
    
    .keyup( function () {
        DateFilter = new Date(this.value).getTime();
        DateFilter = new Date(this.value).getTime();
        oTable.fnDraw();
    });

} );


</script>

</head>

<body>

    <div class="container cont-formulario">
      <!-- Example row of columns -->
      <div class="row">
        <div class="col-lg-5">
          
          <div id="datepickercalendario"></div>
        </div>
      </div>
      
      <p>&nbsp;</p>
      
      <div class="row">
        <div class="col-lg-12">
          <div class="full_width">
            <table cellpadding="0" cellspacing="0" border="0" class="pretty" id="example" >
              <thead>
                <tr>
                  <th>Id</th>
                  <th>Centros de trabajo</th>
                  <th>Categorías</th>
                  <th>Subcategorias</th>
                  <th>Título</th>
                  <th>Lugar</th>
                  <th>Fecha</th>
                  <th>Hora</th>
                  <th>Status</th>
                  <th>url1</th>
                  <th>url2</th>
                </tr>
              </thead>
              
              <tbody>
                <tr>
                  <td colspan="5" class="dataTables_empty">Cargando desde el servidor...</td>
                </tr>
              </tbody>
              
              <tfoot>
                <tr>
                  <th>Id</th>
                  <th>Centros de trabajo</th>
                  <th>Categorías</th>
                  <th>Subcategorias</th>
                  <th>Título</th>
                  <th>Lugar</th>
                  <th>Fecha</th>
                  <th>Hora</th>
                  <th>Status</th>
                  <th>url1</th>
                  <th>url2</th>
                </tr>
              </tfoot>
            </table>
          </div>
        </div>
      </div>
 
    </div>
</body>
</html> 
  #6 (permalink)  
Antiguo 11/08/2014, 07:25
 
Fecha de Ingreso: febrero-2011
Mensajes: 195
Antigüedad: 13 años, 2 meses
Puntos: 1
Respuesta: Datatables, no funciona el paginador

Hola, he estado modificando el codigo pero sin avances, alguien que me pueda ayudar porfavor!!!

Etiquetas: datatables, paginador
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 02:51.