jQuery Datatables: colonne Individuelle de la recherche ne fonctionne pas
J'ai inclus le code qui est présent dans ce lien: https://datatables.net/examples/api/multi_filter.html
Mais il ne fonctionne pas correctement. La recherche de boîtes de montre mais sur le typage des détails dans les zones de recherche les données ne prend pas en charge. Je vais poster le code que j'ai inclus dans mon fichier. Veuillez y jeter un oeil et de vérifier la même.
Toute aide sera grandement appréciée. Merci.
CODE
<div class="col-md-12" style="max-height:300px; display:block; overflow:auto;" >
<table id="big_table" class="table table-striped display table-bordered">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>
</tr>
</tfoot>
<tbody>
<?php foreach($array as $arr) { ?>
<tr>
<td><?php echo $arr->column_1; ?></td>
<td><?php echo $arr->column_2; ?></td>
<td><?php echo $arr->column_3; ?></td>
<td><?php echo $arr->column_4; ?></td>
<td><?php echo $arr->column_5; ?></td>
<td><?php echo $arr->column_6; ?></td>
<td style="text-align:right;"><?php echo $arr->column_7; ?></td>
<td style="text-align:right;"><?php echo $arr->column_8; ?></td>
<td><?php echo $arr->column_9; ?></td>
<td><?php echo $arr->column_10; ?></td>
</tr>
<?php } ?>
</tbody>
JAVASCRIPT
<script>
$(document).ready(function() {
//including input
$('#big_table tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );
//datatable initialization plus exporting to excel
var table = $('#big_table').DataTable( {
dom: 'Bfrtip',
buttons: [
'excelHtml5'
],
"bFilter": false,
"bInfo": false,
} );
//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();
}
} );
} );
} );
</script>
Qu'obtenez-vous dans la console? Aussi avez-vous un tbody? Dans le code html que vous avez posté, il est manquant et que le code est incomplet.
Uncaught ReferenceError: table n'est pas définie
Bon alors, voulez-vous le code pour tbody ainsi?
la version de datatable et jquery utilisez-vous?
Numéro De Version: 1.10.11
Uncaught ReferenceError: table n'est pas définie
Bon alors, voulez-vous le code pour tbody ainsi?
la version de datatable et jquery utilisez-vous?
Numéro De Version: 1.10.11
OriginalL'auteur DEV | 2016-05-10
Vous devez vous connecter pour publier un commentaire.
Semble
bFilter
attribut dans la datatable init est de faire le conflit pour datatable non consultable. Selon les tables de données du site cet attribut doit être défini à true si vous souhaitez effectuer une recherche sur plusieurs colonnes individuellement. Essayez le code ci-dessous pour datatable d'initialisation,Cela devrait fonctionner pour vous maintenant. Cochez cette JSFIDDLE
Si vous voulez faire de la datatable mondiale filtre de recherche pour être désactivé(caché) puis les dom doit être réglé à
lrtp
. Par exemple:dom: 'lrtp'
si vous souhaitez désactiver le mondial de recherche, vous pouvez utiliser le
dom:lrtp
attribut. Content de son travail. 😉Oh merci pour cette homme 🙂
Merci de la Chance bro. a travaillé comme un charme.
Nous avons essayé la même chose dans notre projet et cela ne fonctionne toujours pas; pourriez-vous donner quelques conseils s'il vous plaît? Le code complet de ce qui a été posté par mon coéquipier dans ce fil -> stackoverflow.com/questions/54127446/...
OriginalL'auteur Lucky