1
I have a table structure as follows:
<table id="example" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>Razão Social</th>
<th>CNPJ</th>
<th>CEP</th>
<th>Rua</th>
<th>Cidade</th>
<th>Bairro</th>
<th></th>
</tr>
</thead>
</table>
And the last <th>
there are control buttons that serve for basic CRUD, view, change, delete, create, across this table.
Here is a picture of a piece of the table:
And I have a function that I run when I click on the third icon (#disableCompany), to make a change in the bank:
$(document).on('click', '#disableCompany', function(e){
e.preventDefault();
var uid = $(this).data('id');
$.ajax({
url: 'disableCompany.php',
type: 'POST',
data: {id: uid},
dataType: 'html'
}).done(function() {
$.gritter.add({
title: '<i class="fa fa-exclamation-circle" aria-hidden="true"></i> Empresa desativada com sucesso!',
text: 'A empresa selecionada foi desativada com sucesso! Ela não terá mais acesso ao sistema até que você reative-a novamente.',
class_name: 'gritter-info'
});
setTimeout(function(){
window.location.reload();
}, 5000);
});
});
If the status (1 column) is red (equal to 0, in the data-id attribute), I will send it to the PHP script and then activate (put status 1) and only when I reload the page will the change be seen. There is no way in place of Reload() dynamically update?
The code of the last <tr>
as requested:
"columnDefs": [
{
"targets": 7,
"data": "",
"render": function (data, type, full) {
return '<a data-toggle="modal" data-target="#infoModal" data-id="' + full[7] + '" id="getCompany" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red" href="deleteCompany.php?id_Company=' + full[7] + '"><i class="ace-icon fa fa-trash-o bigger-130"></i></a> <a class="orange" data-id="' + full[7] + '" id="disableCompany"><i class="ace-icon fa fa-eye-slash bigger-130"></i></a>';
}
}]
There are several approaches that may vary according to your html. Post the complete html of the table so that we can analyze more assertively.
– Diego Marques
It’s just html, only table @Diegomarques
– user88879
I mean a three of tboddy
– Diego Marques
@Diegomarques, see the edition if it helps you
– user88879
Some help people?
– user88879
these to return html in json ?
– 13dev
yes @13dev, then it is inserted into the table. It is jquery datatables
– user88879
That’s bad, you should go back to just the necessary data and then join the data with the
html
– 13dev
What about when to change the button? @13dev
– user88879