what is the best way to set scroll bar position?
datavisorfrankhe opened this issue · 4 comments
Hi,
I want to keep scroll position after updating data, is this possible?
Using onScrollEnd, I can get vertical or horizonl scroll position, but after resetting the data, scrollbar goes back to original point, are there any attribute I can set to make table stay at previous scrolling position?
Thanks
Hey, I could use a bit more detail to understand the issue. I believe scroll should stay in the same position on data updates but a few things could alter that so it would be helpful to have more details.
- If rows are sorted or their size changes, the scroll will stay with the scroll offset based in pixels, not with the exact rows.
- If data changes cause the table to shrink the scroll position will be moved to a valid scroll position on the shrunk table (i.e. the max scroll allowed). Issues can occur if changes cause a table to shrink and then re-expand.
Do either of those issues match what you're seeing? If not are there any other details you can give or can you provide a codepen reproducing the issue?
This is what I mean,
Initially, I have 1000 rows, and then I have period checker to update the data status, what I did is just update data directly and enforce the table to redraw using state.
the total rows should be same, data is also same, only some cells have different content.
I think I can update the cell value directly, then table won't scroll back.
but I think there might be some attribute, such as scrollY, and if I passed this value, table will automatically scroll to this position on data changed. Is this possible?
Unfortunately, I can't tell what's going on with only that to go on.
You can use the scrollTop & scrollLeft prop to set the table position if you'd like.
thanks, that should be exactly what I need, thanks