1
Tablodaki belirli bir sütunu, kullanıcının birden çok değeri seçebileceği çoklu bir seçim kullanarak jquery ile filtrelemek istiyorum.Birden çok değeri jquery ile tablodaki tek bir sütundan filtrele
<table id="simple-table" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Codice Pezzo</th>
<th>Descrizione</th>
<th class="center">Fornitore
<div class="col-sm-12">
<select multiple="multiple" class="chosen-select form-control tag-input-style" id="fornitore-select" data-placeholder="Scegli un fornitore..." name="fornitore[]"><option value=""> </option><?php
// esecuzione della query
$query_fornitore = "SELECT p.Marca FROM pezzi p INNER JOIN distinte d ON (d.ID_Pezzo = p.ID_Pezzo) INNER JOIN ordini o ON (o.ID_Impianto = d.ID_Impianto) WHERE o.Data_Consegna >= '".$_GET["data1"]."' AND o.Data_Consegna <= '".$_GET["data2"]."' AND o.Elaborato = 0 GROUP BY p.Marca;";
$result_fornitore = @mysqli_query($conn, $query_fornitore);
// controllo sul numero dei record coinvolti
if(@mysqli_num_rows($result_fornitore)!=0)
{
// risultato sotto forma di array asscociativo
while($row_fornitore = mysqli_fetch_array($result_fornitore, MYSQLI_ASSOC))
{
echo "<option value=\"".$row_fornitore["Marca"]."\">".$row_fornitore["Marca"]."</option>";
}
}
?></select>
</div>
</th>
<th>Quantità</th>
</tr>
</thead>
<tbody id="body-fornitore">
<?php
if(isset($_GET["ordini_materiali"]) && isset($_GET["data1"]) && isset($_GET["data2"])):
$query_distinta = "SELECT d.ID_Pezzo, p.Descrizione, p.Marca, SUM(d.Quantita), o.Quantita FROM ordini o INNER JOIN distinte d ON (d.ID_Impianto = o.ID_Impianto) INNER JOIN pezzi p ON (p.ID_Pezzo = d.ID_Pezzo) WHERE o.Data_Consegna >= '".$_GET["data1"]."' AND o.Data_Consegna <= '".$_GET["data2"]."' AND o.Elaborato = 0 GROUP BY p.ID_Pezzo;";
$result_distinta = @mysqli_query($conn, $query_distinta);
while($row_distinta = mysqli_fetch_array($result_distinta)): ?>
<tr>
<td><?php echo $row_distinta[0]; ?></td>
<td><?php echo $row_distinta[1]; ?></td>
<td class="row-fornitore"><?php echo $row_distinta[2]; ?></td>
<td><?php echo number_format($row_distinta[3]*$row_distinta[4],2,",","."); ?></td>
</tr>
<?php endwhile; endif; ?>
</tbody>
</table>
İşte jQuery kod:: Burada HTML ve PHP kodu ben filtre tablonun tüm sütunlarını dikkate birden choise seçtiklerinde bu yöntemle
$(document).ready(function() {
$('#fornitore-select').change(function() {
var valore = $(this).val() + '';
//console.log(valore);
if(valore == null + '')
{
$('#body-fornitore tr').show();
}
else
{
$('#body-fornitore tr').hide();
$.each(valore.split(","), function(index, item) {
var rex = new RegExp(item, 'i');
$('#body-fornitore tr').filter(function() {
return rex.test($(this).text());
}).show();
});
}
});
});
, ben istiyorum Sadece bir tanesini filtrelemek (spesifik olarak üçüncü). Bunu yapmanın bir yolu var mı? Çıldırıyorum! Sen
Daha önce denedim soruyu gönderme. Artık çalışmıyor. Açılır listeden değeri seçmeye çalıştığımda, satırlar kaybolur. –