I\'m working with jQuery DataTables and server-side processing mode. But I\'m facing an issue with data table, I\'ve search every thing in Datatables documentation but could
In server-side processing mode DataTables expects certain structure in returned data. Parameters draw
, recordsTotal
and recordsFiltered
should be top-level properties. You response has these parameters as sub-properties of data
, not where DataTables would be looking for them.
Set parameters draw
, recordsTotal
and recordsFiltered
as top-level properties of JSON response where DataTables expects them to be.
Use the following code for ajax.dataSrc option:
dataSrc: function(json){
json.draw = json.data.draw;
json.recordsTotal = json.data.recordsTotal;
json.recordsFiltered = json.data.recordsFiltered;
return json.data.data;
}
See this jsFiddle for code and demonstration.