0
I have a page with a datatables, in the event select of this table open a modal passing the id of the selected record to modal, in the modal I delete this record, soon after I close the modal and redirect to the page that was previously, but the table is empty, that is, did not update with the new records.
Table: Javascript
$('#TabEvolucao').DataTable({
"processing" : true,
"select": true ,
"ajax" : {
"type" : "POST",
"url" : "estrutura/tabevolucao.php",
dataSrc : '',
"data" : function(d){
d.idcliente = vlsidcliente;
d.acao = "select";
}
},
"columns" : [ {"data" : "id"},
{"data" : "data"},
{"data" : "descricao"},
{"data" : "nome"},
{"data" : "ativo"}
],
"aaSorting": [[1,'asc']],
"iDisplayLength": 7,
"bFilter": true,
"aaSorting": [[1,'asc']],
"language": {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página ",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
}
});
Sending data from the selected registry to modal: Javascript
var table = $('#TabEvolucao').DataTable();
table
.on( 'select', function ( e, dt, type, indexes ) {
var rowData = table.rows( indexes ).data().toArray();
//events.prepend( '<div><b>'+type+' selection</b> - '+JSON.stringify( rowData )+'</div>' );
//var dt = JSON.stringify( rowData );
var id = rowData["0"].id;
document.getElementById('idevolucao').value = id;
$('#modalVWEVOLUCAO').data('id', id).modal('show');
} )
Delete button in MODAL Javascript
$('#btnUpdateYesEVO').click(function () {
var id = $('#myModalUpdateEVO').data('id');
var idevolucao = document.getElementById('idevolucao').value;
var descricaoevolucao = document.getElementById('descricaoevolucao').value;
var boatao = document.getElementById('acaobotaoevolucao').value;
var iduser=$('#iduser').val();
if(boatao == 'DESATIVAR'){
$.post('estrutura/excluirevolucao.php',{
acao:'delete',
id:id,
user_id:iduser
},function(r) {
var m = jQuery.parseJSON(r);
if (m.success) {
$('#myModalUpdateEVO').modal('hide');
toastr["success"](m.msg);
$("#listevolucao").load(location.href + " #listevolucao>", "");//<<<<<< esta aqui o problema
} else {
toastr["error"](m.msg);
$('#myModalUpdateEVO').modal('hide');
}
});
}
Confusing Java with Javascript is the same thing as confusing a dog with a hot dog. Your question is about Javascript, not Java.
– Victor Stafusa
All right Victor, can you help with that question?
– Jefferson Meireles
I discovered, just update the table.. $('#Tabevolucao'). Datatable().ajax.Reload();
– Jefferson Meireles
Then post your solution as an answer.
– Victor Stafusa