Using data.draw in 'Ajax : function(data, callback, settings)' does not match pager
Using data.draw in 'Ajax : function(data, callback, settings)' does not match pager
pingcrosby
Posts: 29Questions: 4Answers: 1
Can someone explain the correct use of the parameter data.draw. I thought it would match the current page selected by the pager. But it just seems to increment.
The following example will demonstrate.
- Generate any table set it to serverside and the following ajax : function()
dt:ajax
- The table will show an empty table with "showing 1-10 of 50 entries", [prev] [1] [2] [3] [4] [5] [next] buttons
- As you press the pager the alert will show 1,2,3,4,5, but then pressing prev will show 6,7,8,9,10 etc..
the param data.draw always increments. It does not match the page being requested.
serverSide: true,
ajax: function (data, callback, settings) {
alert(data.draw); // data.draw always increases even if you select [previous]
var r = {};
r.draw = data.draw;
r.data = {};
r.recordsTotal = 50;
r.recordsFiltered = 50;
callback(r);
}
This discussion has been closed.
Replies
Two minutes after posting found this
https://www.datatables.net/manual/server-side
Its all clearly explained what data.draw does and that i need to use the data.start parameter.
Sorry to have wasted anybodys time