scrollTo with wrapped columns scrolls to wrong place. How to fix?
scrollTo with wrapped columns scrolls to wrong place. How to fix?
I have a serverSide table ('#my_customers_table') with scrollY: "300px" and scroller: true.
Each row has a cell that opens a modal, and after changing some values there I need to redraw the table (showing the changes), and scrolling to the row that was changed.
Scrolling goes to correct place with:
$('#my_customers_table tbody').on( 'click', 'tr', function () {
localStorage.setItem('my_user_table_selectedrow',$(this).index());
});
and
fnDrawCallback: function() {
my_userTable.row(parseInt(localStorage.getItem('my_user_table_selectedrow'))).scrollTo();
});
But there's a problem that some rows have a lot of text that I need to wrap, unless I want table 5000+ px wide, so I added
div.DTS tbody th, div.DTS tbody td {
white-space: normal !important;
}
After that, scrollTo scrolls to (I presume) the place where the row would be if it were not wrapped, i.e in a very wrong place far above the correct one.
Is there a way for scrollTo to take account the height of each row and calculate the correct scrolling poinnt?
Answers
PS. Added Fiddles to illustrate:
https://jsfiddle.net/Preservin/Lh9g2xj2/4/ (no-wrap. working well)
vs.
https://jsfiddle.net/Preservin/Lh9g2xj2/3/ (wrapped, scrolling to wrong place)