I have a code in codeigniter, and i am using a data-table, now i want to make a show/hide columns with a checkbox above to let the columns hide or maybe shown. I will populate my data from my database in my controller with these code :
public function dataTable_report($date) {
$user = array('user_id' => $this->session->userdata['logged_in']['user_id']);
$myreport = $this->Adminreport_model->getreportDataDaily($user,$date);
$data = array();
foreach ($myreport as $patient) {
$row = array();
$row[] = $patient->check_up_id;
$row[] = $patient->patient_fname;
$row[] = $patient->patient_lname;
$row[] = $patient->patient_mname;
$row[] = $patient->check_up_date;
$row[] = $patient->clinic_name;
$row[] = $patient->bill_amt;
$data[] = $row;
}
$output = array(
"data" => $data,
);
echo json_encode($output);
}
now here is my data-table that doesn't hide when i check my checkbox above please help me: /
I have a code in codeigniter, and i am using a data-table, now i want to make a show/hide columns with a checkbox above to let the columns hide or maybe shown. I will populate my data from my database in my controller with these code :
public function dataTable_report($date) {
$user = array('user_id' => $this->session->userdata['logged_in']['user_id']);
$myreport = $this->Adminreport_model->getreportDataDaily($user,$date);
$data = array();
foreach ($myreport as $patient) {
$row = array();
$row[] = $patient->check_up_id;
$row[] = $patient->patient_fname;
$row[] = $patient->patient_lname;
$row[] = $patient->patient_mname;
$row[] = $patient->check_up_date;
$row[] = $patient->clinic_name;
$row[] = $patient->bill_amt;
$data[] = $row;
}
$output = array(
"data" => $data,
);
echo json_encode($output);
}
now here is my data-table that doesn't hide when i check my checkbox above please help me: https://jsfiddle/2j6w9hqt/27/
Share Improve this question asked Feb 27, 2017 at 4:08 Jc JohnJc John 1,8592 gold badges41 silver badges78 bronze badges1 Answer
Reset to default 3I would not remend manipulating columns visibility by just hiding th
element.
Instead look into using Buttons extension and colvis
button.
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
extend: 'colvis',
columns: ':not(:first-child)'
}
]
} );
See this example for code and demonstration.
I have also modified default appearance of the column visibility button by adding checkboxes, see this answer for more details.