I'm using servers in the datatable JQuery. PHP plus JQuery. The data is pulled from the database. I have specified that 9 records appear on each page (of pagination). But I need it when I start looking for something I want the paging to cease to exist and list 'all' records. And when you stop searching, return to normal with only 9 records per page and pagination. I know the datatable is flexible and has the API commands to change this, the problem and I do not know what it is.
Any help?
example:
<script>
table = $(#table).datatable({
"processing": true,
"serverSide": true,
"order": [],
"ajax": {
"url": "<?php echo site_url('Locacao/ajax_list')?>",
"type": "POST",
},
"pageLength": "9",
"bPaginate": true
})
</script>
php methodh:
class Locacao extends CI_Controller {
public function __construct(){
$parente = parent::__construct();
$this->load->model('Locacao_model','locacao');
}
public function ajax_list()
{
$list = $this->locacao->get_datatables();
$data = array();
$no = $_POST['start'];
foreach ($list as $locacao) {
$no++;
$row = array();
$row[] = $locacao->id;
$row[] = $locacao->name;
$row[] = $locacao->date;
$data[] = $row;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->locacao->count_all(),
"recordsFiltered" => $this->locacao->count_filtered(),
"data" => $data,
);
echo json_encode($output);
}
}