pupudu / window-table

Windowing Table for React based on React Window
https://window-table.netlify.com/
170 stars 13 forks source link

Unable to scroll to row? #50

Closed jakub-astrahit closed 4 years ago

jakub-astrahit commented 4 years ago

Is there a way I can tell the table to scroll to a given row? For example, I have a table with 20 000 rows and I want to scroll to row number 4500. I couldn't find anything like this in the docs and/or in the issues here.

gabrielbezerra81 commented 4 years ago

I was able to do this changing scrollTop of a specific div element that is parent of the second table (the body). Here my rows have fixed height of 43px, then pass the number of rows you want to scroll, and add or subtract depending if you want scroll down or up. Also give an ID to the Window Table element.

var parent = document.getElementById("myTable").childNodes[1]; var scrollDiv = parent.lastChild; scrollDiv.scrollTop += 43 * numberOfLinesToScroll;

hipstersmoothie commented 4 years ago

That doesn't really seem like the best solution. The underlying library support this.This package should too https://react-window.now.sh/#/examples/list/scroll-to-item