How to scroll the datatable view to the bottom on add row function.
How to scroll the datatable view to the bottom on add row function.
In my project, I'm combining :
ScrollY:
https://datatables.net/examples/basic_init/scroll_y.html
Form Inputs:
https://datatables.net/examples/api/form.html
and Add Row:
https://datatables.net/examples/api/add_row.html
Everything is working well except for one tiny thing...
If the user scrolls all the way down to the bottom of the datatable, then presses the Add Row button, the new row shows up at the bottom of the list but it is not visible. The user then needs to scroll down a little further in order to actually see the row and enter their data. (I'm using the .draw(false);
code.)
I've searched the forums here for an answer to this, and tried a few things... I've even tried a few jQuery specific things I've found elsewhere. But, nothing's worked.
Anyone have some code for the Add Row button that would force the scroll to go all the way down to the bottom?
Thanks!
This question has an accepted answers - jump to answer
Answers
Sure, this works for me
http://live.datatables.net/yeludani/1/edit?js,output
Keep in mind, if they sort a column that may put the row on top, this will then hide that row..
Thanks.
That worked like a charm.