('#tabla_diccionarios tfoot th').each( function () {
var title = $(this).text();
if(title=="Key" || title=="Nombre")
$(this).html( '<input type="text" />' );
} );
我需要在特定的列中进行搜索,图像如下: table header & search photo
仅在名为“ Key”和“ Nombre”的列中
这是我的代码
var table = $('#tabla_diccionarios').DataTable( {
"pagingType": "simple_numbers",
"language": "json",
"lengthMenu": [[-1, 10, 25, 50], ["Todos", 10, 25, 50]],
"language": {
"lengthMenu": "Mostrar registros _MENU_ ",
"zeroRecords": "No se encontraron resultados.",
"info": "Mostrando registros del _START_ al _END_ de un total de
_TOTAL_ registros.",
"infoEmpty": "No hay registros disponibles",
"infoFiltered": "(filtrado de un total de _MAX_ registros)",
"paginate": {
"previous": "Anterior",
"next": "Siguiente",
},
"search": "Buscar: ",
}
});
$('#tabla_diccionarios tfoot th').each( function () {
/* var title = $(this).text(); */
$(this).html( '<input type="text" />' );
} );
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
我该怎么做? 谢谢!
答案 0 :(得分:1)
只需弄清楚:
('#tabla_diccionarios tfoot th').each( function () {
var title = $(this).text();
if(title=="Key" || title=="Nombre")
$(this).html( '<input type="text" />' );
} );