ajax function called only once when using scroller
ajax function called only once when using scroller
I'm using a function to supply data using the ajax parameter.
$("#StructureTable").DataTable( {
serverSide: true,
ajax: supplyData,
deferRender: true,
scrollX: true,
scrollY: 500,
scroller: {
loadingIndicator: true,
displayBuffer: 20,
rowHeight: 200,
},
order: [],
lengthChange: false,
lengthMenu: false,
autoWidth: false,
columns: Columns,
fixedColumns: {
leftColumns: 2
},
fixedHeader: true
}
Note: var Columns is predefined properly in earlier code.
This works perfectly for the first page of data using this function.
function supplyData(d, callback, settings) {
// takes the place of ajax to get rows of data
callback({
draw: d.draw,
data: JData.data.slice(d.start, d.start+d.length),
recordsFiltered: d.length,
recordsTotal: JData.data.length
});
};
But the supplyData function is never called again as the page is scrolled.
I was expecting the ajax function to be called whenever needed for scrolling - not just the first time.
Answers
Without setting up a test case I'm not sure why the
supplyData
function is called once. Maybe I'm wrong but it seems like you have a variableJData
that contains all the data sitting in your client and you are using server side processing to access it. If this is the case why don't you just load the whole set of data, usingdata
, into the Datatable and not use server side processing?Is there a problem you are trying to solve using server side processing this way?
Kevin