-
-
Save chelohl11/e3a422c3393c56fcef74b9e859f5c305 to your computer and use it in GitHub Desktop.
DataTable añadir buscador por columna parte superior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="tableListarItems" class="table table-hover table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"> | |
<thead> | |
<tr> | |
<th>Id</th> | |
<th>Referencia 1</th> | |
<th>Referencia 2</th> | |
<th>Descripción</th> | |
<th>Modelo</th> | |
<th>Detalle</th> | |
<th>Comando</th> | |
</tr> | |
<tr> | |
<th>Id</th> | |
<th class="buscar">Referencia 1</th> | |
<th class="buscar">Referencia 2</th> | |
<th class="buscar">Descripción</th> | |
<th class="buscar">Modelo</th> | |
<th class="buscar">Detalle</th> | |
<th></th> | |
</tr> | |
</thead> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
orderCellsTop: true, | |
initComplete: function () { | |
$('#tableListarItems thead tr:eq(1) th.buscar').each( function () { | |
$(this).html( '<input type="text" class="form-control" style="width:100%;"/>' ); | |
}); | |
table.columns([1,2,3,4]).every(function (index) { | |
$('#tableListarItems thead tr:eq(1) th:eq(' + index + ') input').on('change', function () { | |
table.column($(this).parent().index() + ':visible') | |
.search(this.value) | |
.draw(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment