edit/delete datatables in codeigniter
edit/delete datatables in codeigniter
rakanugro
Posts: 3Questions: 3Answers: 0
so far I can display data properly from datatables,when I use the columns[] on ajax script to make edit/delete
the data can't display properly here my code
view:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID Category Asset</th>
<th>Category Name</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID Category Asset</th>
<th>Category Name</th>
</tr>
</tfoot>
<tbody>
</tbody>
</table>
controller
public function ac_page(){
$this->load->model('edit_model');
$ac = $this->edit_model->load_ac();
//variables
$draw = intval($this->input->POST('draw'));
$start = intval($this->input->POST('start'));
$length = intval($this->input->POST('length'));
$data = array();
foreach ($ac as $row ) {
$data[] = array(
$row->Category_ID,
$row->Category_name
);
}
$acfull = $this->edit_model->load_acfull();
$output = array(
"draw" => $draw,
"recordstotal" => $acfull,
"recordsfiltered" => $acfull,
"data" => $data
);
echo json_encode($output);
exit();
}
ajax
$(document).ready(function() {
$('#example').DataTable({
"processing": true,
"ajax" :{
url : "<?php echo base_url()?>Edit_asset/ac_page",
type : 'POST'
},
//"columns": [
//{ "data": "Category_ID" },
//{ "data": "Category_name" }
//]
});
});
the question is how to make edit/delete and display data properly
This discussion has been closed.