2
I’m using the Datatable Server-side, but I’m not sure how to catch the ID
from my table to open the edit and delete pages.
server-side
$table = 'financ_receita';
$primaryKey = 'ID_Receita';
$columns = array(
array( 'db' => 'ID_Receita', 'dt' => 0 ),
array( 'db' => 'nome', 'dt' => 1 ),
array( 'db' => 'valor', 'dt' => 2 ),
array( 'db' => 'dataVenci', 'dt' => 3 ),
array( 'db' => 'formaEntrada', 'dt' => 4 ),
);
Table mount
var myTable =
$('#dynamic-table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "dados.php",
"columns": [{
"bVisible": false,
"bSortable": false
},
null,
null,
null,
null,
{
data: null,
className: "center",
defaultContent: '<a href="editar?id=" class="editor_edit button blue">Editar</a> <a href="excluir?id=" class="editor_remove button red">Del</a>',
orderable: false,
bSearchable: false,
}
],
"language": {
"url": "/assets/js/dataTables/lang/pt-br.json"
},
});
I’d like to put the Id_recipe in the respective links: editar?id=
and excluir?id=
.
Good morning Sam. How do I get the
render
read functiononClick="return false;"
.'<a href="financeiroContaAreceberEpagar.php?id='+data[0]+'&i=3d" class="btn-link no-border red delete-event" data-title="Apagar" data-content="Deseja apagar esse lançamento?" onClick="return false;"><i class="ace-icon fa fa-trash-o bigger-130"></i></a>' +
– Tiago
I am organizing in this way https://prnt.sc/o4uay4
– Tiago
Good morning. I don’t quite understand the onclick function. You want to override the link redirect?
– Sam
How the data is coming via ajax, and using the
render
to display the View, Edit and Delete controls, it seems that thereturn
ofrender
is nullifying myonClick="return false;"
, this function just opens the modal asking if you really want to delete.– Tiago
On the edit button, I have a class called
link
where she is just to identify that other function$(".link").mouseover(function(){
 var href = $(this).attr('href');
 $('.iframe').attr('src', href)
 });
which passes the href into thesrc
iframe, so that the modal opens the page. For some reason also does not recognize.– Tiago
Do so:
$(document).on("mouseover", ".link", function(){
– Sam
It worked. Thank you Sam
– Tiago