Function after redrawing a table
Function after redrawing a table
Hello there,
I am building datatable with input in every row (over 4k rows). User can filter and edit every input. After submiting the form, I would like to take all the data and send it to server.
Right now, I am using this to append all rows to first page.
otabulka.rows().nodes().page.len(-1).draw(false);
But after redrawing, I would like to submit form:
$('#hlavni_form').submit();
But I need to submit it after all of the rows where appended. In other words, when the draw function is complete. I am trying to do this:
otabulka.on( 'draw', function () {
console.log( 'Redraw occurred at: '+new Date().getTime() );
});
But it does not work. (does not write anything in console).
Thank you for your help.
This question has an accepted answers - jump to answer
Answers
That looks like it should work. And it does here. It doesn't on the very first draw of the table since the event hasn't been added then, but I don't think that's the issue you are seeing).
Allan
Thank you for yor response. Your link is working, but I tried to move "on draw" listener in the click functon:
And it stopped working. What do you think is the issue here?
The thing is... when i put the draw listener outside the click, it does work. But it is initiated everytime when somebody filter data etc.
I need catch the moment when the redrawing is finished (every row is appended to the the first page) and then submit the form
You are adding the
draw
event listener after you calldraw()
. Add it outside of the click (otherwise its going to add another event listener every time you click the button).Thanks,
Allan
Thank you!