I am trying to make dynamic the data table in server side that I've found through the internet(for preference http://mbahcoding.com/tutorial/php/codeigniter/codeigniter-simple-server-side-datatable-example.html) because in this tutorial the table and the columns is fixed.
Controller
public function __construct()
{
parent::__construct();
$this->load->model('CrudModel');
$this->load->model('AccountModel');
$this->load->model('customers_model','customers');
}
public function ajax_list()
{
// $list = $this->customers->get_datatables();
$list = $this->AccountModel->get_datatables('customers'); //my table name
$data = array();
$no = $_POST['start'];
foreach ($list as $customers) {
$no++;
$row = array();
$row[] = $no;
$row[] = $customers->FirstName;
$row[] = $customers->LastName;
$row[] = $customers->phone;
$row[] = $customers->address;
$row[] = $customers->city;
$row[] = $customers->country;
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->customers->count_all(),
"recordsFiltered" => $this->customers->count_filtered(),
"data" => $data,
);
//output to json format
echo json_encode($output);
}
The question is where $this->customers->count_all() and count_filtered() come from?