I have the following checkboxes:
<div class="row smart-form">
<section class="col col-1.5">
<label class="toggle">
<input type="checkbox" name="checkbox-toggle" rel="Natureza" value="Produtos">
<i data-swchon-text="ON" data-swchoff-text="OFF"></i>
Produtos</label>
</section>
<section class="col col-1.5">
<label class="toggle">
<input type="checkbox" name="checkbox-toggle" rel="Natureza" value="Produtos Auto-Utilizados">
<i data-swchon-text="ON" data-swchoff-text="OFF"></i>
Produtos Auto-Utilizados</label>
</section>
</div>
I have this table that will fetch data from DB:
<table id="datatable_fixed_column" class="table table-striped table-bordered" width="100%">
<thead>
<tr class="first">
<th>Código</th>
<th>Nome</th>
<th>Descrição</th>
<th>Designação Comercial</th>
<th>Unidades</th>
<th>IVA %</th>
<th>Stock</th>
<th>Natureza</th>
</tr>
</thead>
<tbody>
@for(art <- artigos) {
<tr>
<td>@art.getId()</td>
<td>@art.getNome()</td>
<td>@art.getDescricao()</td>
<td>@art.getDesignacaoComercial()</td>
<td>@art.getIva().getValor()</td>
<td>@art.getStockAtual()</td>
@for(nat <- art.getDesignacoes()) {
<td> @nat.getGestaoComparativa().getNatureza().getDescricao()</td>
}
</tr>
}
</tbody>
</table>
JavaScript
$("input:checkbox").click(function () {
var showAll = true;
$('tr').not('.first').hide();
$('input[type=checkbox]').each(function () {
if ($(this)[0].checked) {
showAll = false;
var status = $(this).attr('rel');
console.log("STATUS: " + status);
var value = $(this).val();
console.log("VALUE: " + value);
$('td.' + status + '[rel="' + value + '"]').parent('tr').show();
}
});
if(showAll){
$('tr').show();
}
});
I still do not understand why I'm not working. I do not quite understand what "rel= "
is for. I tried to tailor the code from this font .
Whenever I load a checkbox, all data disappears. I would like someone to help me interpret the source code to figure out where to get the names that are filtered and the columns.
PS: I just need to filter the data in the Nature column.