In my dataTable, I have a hidden column has contain the name of current Status of the data in closest row but when press the input checkbox, change text of that hidden column from this way:
$("#rBuscarPerfil").on('click','input[type="checkbox"]',function() {
if($(this).is(':checked')) {
$(this).closest('tr').find('td:last').html("Activo");
} else {
$(this).closest('tr').find('td:last').html("Desactivado");
}
........
}
And when press the buttons of top, for example:
Active, in the input search of dataTable placed text "Activo" and table show only results has contain in the last td of each row, "Activo" word.
Inactivo, placed text in the input search of dataTable and display only results has contain in the last td of each row, "Desactivado" word.
The problem is this: The search works only when open the page or refresh browser but if I check or uncheck any checkbox in each row, the text in last TD the text in the last row, change correctly. But it seems that the table is in a current state and does not update its attributes and the search does not show results with those changes.
Html code table
<table cellspacing="1" id="rBuscarPerfil" class="tableResultsSearch" name="rBuscarPerfil">
<thead>
<tr>
<th>NOMBRE</th>
<th>DESCRIPCIÓN</th>
<th>ACCIÓN</th>
<th>STATUS</th>
<th style="display:none;">STATUS2</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Js to load content in table
if(response.success == "success") {
if(area == "perfil") {
$('#rBuscarPerfil tbody tr').remove();
$.each(response, function (index,record){
if(valNumber(index)) {
var row = $("<tr class='"+record.IdPerfil+"'/>");
$("<td nombre='"+record.NomPerfil+"'/>").text(record.NomPerfil).appendTo(row);
$("<td />").text(record.DesPerfil).appendTo(row);
$("<td />").html("<img src='media/icons/edit_item.png' class='bModifyProfile' cve='"+record.DesPerfil+"' alt='Editar' title='Editar'></img><img src='media/icons/delete_item.png' class='bDeleteProfile' cve='"+record.IdPerfil+"' alt='Eliminar' title='Eliminar'></img>").appendTo(row);
if (record.EdoPerfil == 1) {
$("<td />").html("<input type='checkbox' checked/>").appendTo(row);
row.css("backgroundColor","#b0f2b1");
} else {
$("<td />").html("<input type='checkbox' />").appendTo(row);
row.css("backgroundColor","#ffddec");
}
$("<td style='display:none;' />").text(record.nomStatus).appendTo(row);
row.appendTo("#rBuscarPerfil tbody");
}
});
}
}
var oTable = $('#rBuscarPerfil').dataTable({
"bJQueryUI": true,
"bRetrieve" : true,
"bDestroy" : true,
"aaSorting": [[ 0, "desc" ]],
"sPaginationType" : "full_numbers"
});
oTable.fnDraw();
I hope I have explained.