Search inputs at the top not working
Search inputs at the top not working

Hello, I tried several solutions found on the internet to put the inputs at the top of the table. However none works, so I would like to put the inputs above the thead.
Can you help me on this? Thank you
//Ajout des inputs text pour de la recherche par colonnes
$('#liste-intervention tfoot th').each(function() {
let title = $(this).text();
$(this).html('<input type="text" class="form-control" placeholder="'+ title +'" />');
});
//Initialisation de DataTable avec les doms
let table = $('#liste-intervention').DataTable({
'language': {
"sEmptyTable": "Aucune donnée disponible dans le tableau",
"sInfo": "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments",
"sInfoEmpty": "Affichage de l'élément 0 à 0 sur 0 élément",
"sInfoFiltered": "(filtré à partir de _MAX_ éléments au total)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Afficher _MENU_ éléments",
"sLoadingRecords": "Chargement...",
"sProcessing": "Traitement...",
"sSearch": "Rechercher :",
"sZeroRecords": "Aucun élément correspondant trouvé",
"oPaginate": {
"sFirst": "Premier",
"sLast": "Dernier",
"sNext": "Suivant",
"sPrevious": "Précédent"
},
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre décroissant"
},
"select": {
"rows": {
"_": "%d lignes sélectionnées",
"0": "Aucune ligne sélectionnée",
"1": "1 ligne sélectionnée"
}
}
},
'scrollX': true,
dom: 'Bfrtip',
buttons: [
'csv', 'excel'
]
});
//Recherche dans le tableur
table.columns().every(function() {
let that = this;
$('input', this.footer()).on('keyup change clear', function() {
if(that.search() !== this.value) {
that
.search(this.value)
.draw();
}
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Here is an example:
http://live.datatables.net/cedayopa/1/edit
It uses
orderCellsTop
to move the sorting functions to the top header adn places the inputs in the second header.Kevin