I'm trying to add a button with id
of user to datatables with serverside I made several unsuccessful attempts, if anyone can help me I appreciate it.
This is my code datatables:
$('#jsontable').dataTable({
"oLanguage": {
"sUrl": "busca/pt-br.txt"
},
"responsive": true,
"processing": true,
"serverSide": true,
"ajax": "busca/busca_usuario.php"
});
This is the array of user-search:
$columns = array(
array( 'db' => ''a'.'nome'', 'dt' => 0, 'field' => 'nome' ),
array( 'db' => ''a'.'cpf'', 'dt' => 1, 'field' => 'cpf' ),
array( 'db' => ''a'.'situacao'', 'dt' => 4, 'field' => 'situacao'),
array( 'db' => ''b'.'descricao'', 'dt' => 2, 'field' => 'descricao' ),
array( 'db' => ''c'.'descricao'', 'dt' => 3, 'field' => 'nomegh', 'as' => 'nomegh' ),
);
The data arrives like this:
{"draw":1,"recordsTotal":28,"recordsFiltered":28,"data":[{"0":"ADRIANO TESTE","1":"0000000000","4"
:"ativo","2":"Aluno","3":"Aluno 1ª série"}]}
I was able to add the link to the column only to be able to get the user id:
I leave my attempt to help others with the same doubt:
$('#jsontable').dataTable({
"oLanguage": {
"sUrl": "busca/pt-br.txt"
},
"responsive": true,
"processing": true,
"serverSide": true,
"ajax": "busca/busca_usuario.php",
"aoColumnDefs" : [
{"data": null, "sDefaultContent": "<a href=teste.php?id=' + data[0] + '>teste</a>","aTargets": [5]}
]
});