Pessoal,
Tenho uma tabela dinâmica, onde atualizo ela a cada x tempo.
Mas, queria encontrar uma tabela com opções de mostrar apenas certos valores de uma coluna, ou certos campos.
Um filtro… atualmente o primeiro dado carrego na tela e os demais (a função de refresh) monto a tabela no JS:
<table id="tabelaAlerta" class="table" data-sort="false"
data-page-size="999">
<thead>
<tr>
<th>!</th>
<th>Nível Atual</th>
<th>Dispositivo</th>
<th>Data</th>
<th>Alerta 1</th>
<th>Alerta 2</th>
<th>Excluir</th>
<th>Eventos</th>
</tr>
</thead>
<tbody>
<c:forEach var="listaAlertas" varStatus="alerta" items="${listaAlertas}">
<tr id="cor1">
<fmt:parseNumber var="nvlAlerta" integerOnly="true" type="number" value="${listaAlertas.codNvlAlertaMax}" />
<c:if test="${nvlAlerta >= 3 && nvlAlerta <= 4}">
<td>
<img src="img/medio.png" width="16" height="16" />
</td>
</c:if>
<c:if test="${nvlAlerta >= 5}">
<td>
<img src="img/alto.gif" width="16" height="16" />
</td>
</c:if>
<td><c:out
value='${listaAlertas.codNvlAlertaAtual != "" ? listaAlertas.codNvlAlertaAtual : "-"}' /></td>
<td><c:out value='${listaAlertas.dispositivo}' /></td>
<td><c:out
value='${listaAlertas.dataEnvio != "" ? listaAlertas.dataEnvio : "-"}' /></td>
<td><c:out
value='${listaAlertas.codAlerta1 != "" ? listaAlertas.codAlerta1 : "N"}' /></td>
<td><c:out
value='${listaAlertas.codAlerta2 != "" ? listaAlertas.codAlerta2 : "N"}' /></td>
<td><a href="#"> <img
alt="Excluir Alerta" src="img/delete.png" width="15"
height="15"
onclick="confirmarExcluirAlerta(${listaAlertas.codAlerta})">
</a></td>
<td><a href="#"> <img
alt="Lista de Eventos" src="img/lista256.png" width="15"
height="15"
onclick="listaEventos('${listaAlertas.dispositivo}')">
</a></td>
</tr>
</c:forEach>
</tbody>
</table>
JS:
function atualiza() {
$.ajax({
type : "POST",
url : "ServletAlertaRN"
})
.done(
function(data) {
var dados = "";
$('#tabelaAlerta tbody').html("");
//style='margin-left:40%'
var linkExclusao = "<a href=''#'>"
+ "<img alt='Excluir Alerta' src='img/delete.png' width='15' height='15' onclick='confirmarExcluirAlerta('";
var linkEvento = "<a href=''#'>"
+ "<img alt='Lista de Eventos' src='img/lista256.png' width='15' height='15' onclick='listaEventos('";
data.forEach(function(o) {
dados+="<tr>";
if (parseInt(o.codNvlAlertaMax) >= 3 && parseInt(o.codNvlAlertaMax) <= 4){
dados+="<td><img src='img/medio.png' width='16' height='16' /></td>";
} else if (parseInt(o.codNvlAlertaMax) >= 5){
dados+="<td><img src='img/alto.gif' width='16' height='16' /></td>";
} else {
dados+="<td> - </td>";
}
dados+="<td>" + o.codNvlAlertaAtual + "</td>";
dados+="<td>" + o.dispositivo + "</td>";
dados+="<td>" + o.dataEnvio + "</td>";
if(o.codAlerta1 == "" || o.codAlerta1 == null){
dados+="<td> N </td>";
} else {
dados+="<td>" + o.codAlerta1 + "</td>";
}
if(o.codAlerta2 == "" || o.codAlerta2 == null){
dados+="<td> N </td>";
} else {
dados+="<td>" + o.codAlerta2 + "</td>";
}
dados+="<td>" + linkExclusao + o.codAlerta+ "')'></a></td>";
dados+="<td>" + linkEvento + o.dispositivo+ "')'></a></td>";
dados+="</tr>";
});
$('#tabelaAlerta tbody').append(dados).trigger('footable_redraw');
});
}