why is the data not appearing?

why is the data not appearing?

lurapril12lurapril12 Posts: 2Questions: 2Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
- View-
$(document).ready(function () {
$('#table_memo').DataTable({
'processing': true,
'serverSide': true,
'serverMethod': 'post',
"ajax": "<?php echo site_url('HO/Finance/financeAjax'); ?>",
"column":[{
"data": 'persetujuan'
},{
"data": 'ptnama'
},{
"data": 'nomor_vch'
},{
"data": 'tanggal_trans'
// "data": "Aksi"
}]
});
});

Controllers
public function financeAjax()
{
$param['draw'] = isset($_REQUEST['draw']) ? $_REQUEST['draw'] : '';
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : '';
$length = isset($_REQUEST['length']) ? $_REQUEST['length'] : '';
$search_value = isset($_REQUEST['search']['value']) ? $_REQUEST['search']['value'] : '';

$data = $this->thVoucher->searchAndDisplay($search_value, $start, $length);
$total_count = $this->thVoucher->searchAndDisplay($search_value);

$json_data = array(
  'draw'=> intval($param['draw']),
  'recordsTotal' => count($total_count),
  'recordsFiltered' => count($total_count),
  'data'=> $data
);

return json_encode($json_data);

}

Models
public function searchAndDisplay($like = null, $start = 0, $length = 0 )
{
$builder = $this->dbtests->table("th_voucher");
if($like){
$arr_like = explode(" ", $like);
for ($x = 0; $x < count($arr_like); $x++) {
$builder = $builder->orLike('persetujuan', $arr_like[$x]);
$builder = $builder->orLike('ptnama', $arr_like[$x]);
$builder = $builder->orLike('nomor_vch', $arr_like[$x]);
$builder = $builder->orLike('tanggal_trans', $arr_like[$x]);
}
}
if($start != 0 or $length != 0) {
$builder = $builder->limit($length, $start);
}
// $builder = $this->dbtests->query("
// SELECT DISTINCT b.nama AS ptnama, c.nama AS deptnama, a.keterangan as coa_keterangan, a.*
// FROM th_voucher a
// JOIN
// ".$this->dbdatas->database.".m_pt b ON a.pt_id=b.pt_id
// JOIN
// ".$this->dbdatas->database.".m_departemen c ON c.departemen_id = a.departemen_id
// LEFT JOIN ".$this->dbdatas->database.".t_aksespt e ON a.pt_id = e.pt_id
// WHERE a.nomor_vch LIKE '%".$like."%' OR year(a.tanggal_trans) LIKE '%".$like."%' OR kode_prefik LIKE '%".$like."%' OR keterangan LIKE '%".$like."%' OR persetujuan LIKE '%".$like."%'
// ORDER BY a.pt_id,a.tanggal_trans DESC;
// ");
if($start != 0 or $length != 0) {
$builder = $builder->limit($length, $start);
}
return $builder->get()->getResultArray();
}

Error messages shown:

Description of problem:
That's why the data I want to display doesn't appear, but the serverside datatable does. Just show it, can't do it, what should I do?

Answers

  • allanallan Posts: 63,676Questions: 1Answers: 10,497 Site admin

    There is a good chance I'll need a link to the page showing the issue for this one please. It might be a CSS error where you just can't see the text, or it might be that the JSON properties aren't what is configured, or that the data is empty strings. I don't know without being able to see the page, or at the very least the JSON return from the server please.

    Allan

Sign In or Register to comment.