Rest scrollX position after button click.
Rest scrollX position after button click.
I have a view that has a table with a lot of columns so I'm using the scrollX feature. In this view I can dynamically add rows. Typically the data flow is the user will enter data and go to the far right of the screen before adding a new row. So when the new row is added the scroll position should go back to the far left. I've tried destroying and recreating the table before adding the row but it always removes the dynamically added row. How can I reset the scrollX position of the datatable?
This question has an accepted answers - jump to answer
Answers
You can use scrollLeft() - just call that before adding your row,
Colin
What element do I do the scrollLeft on? Is it $('#table).scrollLeft() ?
It seems like the scroll is on the dataTables_scrollBody class
https://datatables.net/forums/discussion/6635/fixed-columns-auto-horiz-scroll-to-right-on-load
Yes it is. Thank you colin.
The process is same for ScrollRight?
@Frandollow Yep, it would be - it's just a jQuery method for a scrollable element.
Colin
okey! That's great! Thank you @colin