Lightning Web Components: Set scroll position on lightning-datatable based on ‘key’ field value

We are looking to auto-scroll the user to a specific point in a lightning-datatablewhen a button is clicked.

Assuming we referenced the key-field attribute data-row-key-value in the dom then in HTML I could:

  1. Get the scrollTop position of the scrollable div (let’s call it tbl).
  2. Find the appropriate tr (let’s call it trgt).
  3. Set tbl.scrolltop = trgt.offsetTop - tbl.offsetTop.

Is anything like this possible in LWC without access to the DOM elements through window?


Source : Link , Question Author : Dan Nicholson , Answer Author : Community

Leave a Comment