Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82031

pass multi dimension array to datatables in codeigniter

$
0
0

Hi Everyone,

I have use datatables for my website (I use codeIgniter framwork) and it's work. but now i have problem when I use multi dimension array,

this my code

    function data_attend()
    {
        $w          = $this->input->post("write");
        $d          = $this->input->post("delete");
        $lab_slct           = $this->input->post("lab_slct");
        $month_slct = $this->input->post("month_slct");
        $year_slct  = $this->input->post("year_slct");
        $draw       = intval($this->input->get("draw"));
                $start      = intval($this->input->get("start"));
                $length             = intval($this->input->get("length"));
        $data = array();
        $attend_test    = $this->m_human_capital->attend_test();
        $month = $this->m_general->month($month_slct)->row_array();
        $day_total  = $month['day_total'];
        $holiday    = $this->m_general->holiday()->result();
        $month      = $this->m_general->list_month()->result();
        $year       = $this->m_general->list_year()->result();
        $rows       = $this->m_human_capital->attendance($lab_slct, $keyword)->result_array();
        $a          = array();
        foreach ($rows as $row) {
            $a[$row['sn']][] = $row;
        }
            $rows2          = $a;
        $attendance_2   = $this->m_human_capital->attendance_2(array('ab.lab'=>$lab_slct));
        $roaster        = $this->m_general->get_data('tb_roaster')->result_array();
        $attend_detail  = $this->m_general->get_data('tb_attend_detail')->result_array();
        $no=1;
        foreach ($attendance_2->result_array() as $attend_list) {
            foreach ($rows2 as $i){
                if ($i = $attend_list['sn']) {
                    $a = $attend_list['name'];
                    $b = $attend_list['pst_desc'];
                    for($m=1; $m <= $day_total; $m++){
                        $c=$m;
                    }
                    $d = array();
                    $d[] = implode(',',$c);
                }
            }
            $data[] = array (
                $no++,
                $a,
                $b,
                $d (i want to show array $d here)
            );
        }
        $output = array(
                    "draw"              => $draw,
                "recordsTotal"      => $attendance_2->num_rows(),
                "recordsFiltered"   => $attendance_2->num_rows(),
                "data"              => $data
            );
        echo json_encode($output);
    }

this my javascript

$(document).ready(function() {
$("#attendance_list").DataTable({
"ajax": {
"url": base_url+"human_capital/data_attend",
"type": "POST",
"data": {
"write": $("#write").val(),
"delete": $("#delete").val(),
"lab_slct": $("#lab_slct").val(),
"month_slct": $("#month_slct").val(),
"year_slct": $("#year_slct").val()
}
}
});
});

my data just show column 1 until 3, but for column 4 just shown last array $d.


Viewing all articles
Browse latest Browse all 82031

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>