Data tables sorting , pagination and column searching are not working fully
Data tables sorting , pagination and column searching are not working fully
I made a server-side processing data table.
I have 3000 entries in my datatable
It was working fine before a week but now I am not able to sort some columns in descending order, search some column, and pagination after 17th page.
My sorting query is:
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; // adding length
My column search query is:
if( !empty($requestData['columns'][i]['search']['value']) ){ //name
$sql.=" AND id LIKE '%".$requestData['columns'][i]['search']['value']."%' ";
}
And my data table jquery is:
$(document).ready(function() {
var dataTable = $('#example').DataTable( {
dom: "Bfrtip",
scrollY: "75vh",
"scrollX": true,
"iDisplayLength": 25,
"order": [[ 14, "desc" ]],
ajax: {
url: "server_processing.php",
type: "post"
},
serverSide: true,
select: true,
buttons:['pageLength','copy', 'csv', 'excel',
{
extend: 'print',
exportOptions: {
columns: ':visible'
}
},
{
text: 'Update',
className: 'edit',
enabled: false,
action: function (e, dt, node, config) {
var modal = document.getElementById('updateModal');
modal.style.display = "block";
}
},
{
text: 'Delete',
className: 'delete',
enabled: false,
action: function (e, dt, node, config) {
var delmodal = document.getElementById('deleteModal');
delmodal.style.display = "block";
}
},
'colvis'
],
columnDefs: [{
"targets": [ 0 ],
"visible": false,
"searchable": false
}],
});
I am constantly getting an error- DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Kindly help me out,
Facing this issue since 2 weeks and can't figure out what is the problem.