0
I’m trying to put action buttons on my table through the datatTable plugin.
My Javascript code
$(document).ready(function(){
var table = $('#dataTable').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"contentType": "application/json",
"url": "http://localhost:8000/usuario/listar"
},
"columnDefs": [{
"targets": -1,
"data": null
}
}]
});
});
and my Codeigniter Controller
<?php
class Usuario extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('UsuarioModel');
}
public function listar(){
$data = $this->UsuarioModel->all()->result();
$row = [];
foreach($data as $dados){
$row[] = array($dados->nome, $dados->endereco);
}
$d['data'] = $row;
echo json_encode($d);
}
}
The idea is that by Datatable it create action buttons with "edit", "remove", "view" with the id on the button of my json reply.
By the code presented you are not creating the buttons, for Datatables. You can do this creation by PHP itself.
– PaulinhoCaP