filtrado por columnas

filtrado por columnas

josecito123josecito123 Posts: 1Questions: 1Answers: 0
edited August 2020 in Free community support

He implementado el filtrado por columnas con el siguiente codigo:

<

script>

$(document).ready(function(){
    var table = $('#example').DataTable({
       orderCellsTop: true,
       fixedHeader: true 
    });

    //Creamos una fila en el head de la tabla y lo clonamos para cada columna
    $('#example thead tr').clone(true).appendTo( '#example thead' );

    $('#example thead tr:eq(1) th').each( function (i) {
        var title = $(this).text(); //es el nombre de la columna
        $(this).html( '<input type="text" placeholder="Search...'+title+'" />' );
 
        $( 'input', this ).on( 'keyup change', function () {
            if ( table.column(i).search() !== this.value ) {
                table
                    .column(i)
                    .search( this.value )
                    .draw();
            }
        } );
    } );   
});

</script>

pero me regresa el siguiente mensaje:

DataTables warning: table id=example - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

Pudieran ayudarme, por favor

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    That script looks OK, so we would need to see the issue occurring to be able to debug. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.