I want change visibility of a columns with inputs in a datatable, i use a checkbox function to filter fields and this inputs, when you clicked the checkbox the datatable hidden certains columns but not the inputs (The inputs filter too)
Here the code:
<thead>
<tr>
<th>Documento</th>
<th>Fecha creacion</th>
<th>Descargar</th>
<th>Visualizar</th>
</tr>
</thead>
<thead class="filters">
<tr>
<td>Documento</td>
<td>Fecha creacion</td>
<td>Descargar</td>
<td>Visualizar</td>
</tr>
</thead>
And the jquery functions:
$('#tabla_bajas .filters td').each( function () {
var title = $('#tabla_bajas thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
var table = $('#tabla_bajas').DataTable();
// Apply the search
table.columns().eq( 0 ).each( function ( colIdx ) {
$( 'input', $('.filters td')[colIdx] ).on( 'keyup change', function () {
table
.column( colIdx )
.search( this.value )
.draw();
} );
} );
$('#myCheck1').change(function() {
table.columns(0).visible(!$(this).is(':checked'))
//here i want change visibility of the inputs
console.log(table.columns(0));
});
$('#myCheck2').change(function() {
table.columns([1, 2]).visible(!$(this).is(':checked'))
})
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire