Первая страница с 10 записями:
Вторая страница, позиции 11–20 добавлены ниже

Вот мой код для view.php
var table = $('#impDT').DataTable({
"language": {
"processing": ""
},
"aLengthMenu": [[10, 25, 50], [10, 25, 50]],
"processing":true,
"serverSide":true,
"order":[],
"ajax":{
url:'impEntryDT',
type:"POST"
},
"columnDefs":[
{
"targets":[5],
"orderable":false,
},
],
dom:'lBfrtip',
buttons: [
{
extend: 'excelHtml5',
text: ' Excel',
className: 'export-btn',
titleAttr: 'Excel',
title: 'Excel- Formal Entry'
},
{
extend: 'csvHtml5',
text: ' CSV',
className: 'export-btn',
titleAttr: 'CSV',
title: 'CSV- Formal Entry'
},
{
extend: 'pdfHtml5',
text: ' PDF',
className: 'export-btn',
titleAttr: 'PDF',
title: 'PDF - Formal Entry'
},
{
text: '',
className: 'refresh-btn',
action: function ( e, dt, node, config ){
table.clear().draw();
table.ajax.reload();
}
}
]
});
Controller.php
public function get_formal_list(){
$entry = 'formal';
$output = array(
"draw" => intval($_POST["draw"]),
"recordsTotal" => $this->Formal_m->get_all_data($entry),
"recordsFiltered" => $this->Formal_m->get_filtered_data($entry),
"data" => $this->Formal_m->make_datatables($entry)
);
echo json_encode($output);
}
Model.php
public function make_datatables($entry){
$COMINS2 = $this->load->database('comins2', TRUE);
if($entry == 'formal'){
$COMINS2->select('*')
->from('TBLIMPAPL_MASTER');
if(isset($_POST["order"])) {
$COMINS2->order_by($this->order_column[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
}else{
$COMINS2->order_by('ApplNo', 'DESC');
}
if($_POST["length"] != -1){
$COMINS2->limit($_POST['length'], $_POST['start']);
}
$result = $COMINS2->get()->result();
return $this->formal_domain_logic($result, $entry);
}
}
public function formal_domain_logic($fetch_data, $entry){
$data = array();
foreach($fetch_data as $row){
$sub_array = array();
$sub_array[] = "
".$row->ApplNo."
Подробнее здесь: [url]https://stackoverflow.com/questions/52982704/datatables-pagination-next-button-only-appends-data-not-changing-page
Мобильная версия