DataTable initialization calls draw twice because of paging
DataTable initialization calls draw twice because of paging
Hello dear community,
I have a more general question. I have a DataTable which is initialized with
serverSide: true,
ajax: "insert url here",
responsive: {
//some stuff here
},
pageLength: 100,
stateSave: true
I wondered why my table takes so long to initialize. So I checked out the draw calls of the DT. I recognized that the first draw is done with
start: 0
length: 100
and the second one as well with
start: 0
length: 100
But when I swapped to the second page and reload the page, then the first call is done with:
start: 0
length: 100
but the second one is
start: 100
length: 100
I know that an ajax call is made everytime the table needs to draw.
What are the common mistakes which produces more calls than necessary during initialization?
Thanks for your input.
Pichutan
Answers
This example with server side processing and stateSave doesn't exhibit that behavior:
https://live.datatables.net/yaroyala/67/edit
It just goes to the page saved by stateSave.
There must be something more happening on your page. Maybe you have an event firing that is calling
draw()
. Can you post a link to your page or a test case so we can take a look? Feel free to update my example.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin