0

Is there a way to scrollTo an element by ID or any other attribute except index?

I have really long lists (inside accordions) and I have the id of the highlighted div and would like to scroll to it. Problem is I could use doc.getElemById but the element isnt in the dom :(

prgrmr
  • 842
  • 3
  • 14
  • 30

1 Answers1

0

No. react-virtualized doesn't know anything about the data in a cell. (This enables it to work with arrays, immutable objects, etc.) You'll need to manage your own map of id-to-index somehow.

bvaughn
  • 13,300
  • 45
  • 46
  • :( ok. Do you have any suggestions on how I might be able to achieve it? – prgrmr Jun 23 '17 at 18:08
  • How you could manage an id-to-index map? Not without knowing your data or your application, no. – bvaughn Jun 23 '17 at 18:14
  • No worries @brianvaughn just figured it out... BTW I have to say a BIG THANK YOU for an amazing component and being super responsiveness :) #respect #takeABow – prgrmr Jun 23 '17 at 18:35
  • @prgrmr could you please share your solution? Thks in advance – Carlos Mendes Jul 14 '17 at 22:58
  • 1
    Hey @CarlosMendes the thing is I added a data-index attribute to store the index. Doing that when the list gets generated. That ways whenever you want to target an element by id you just look up the index and pass it to react virtualized – prgrmr Jul 16 '17 at 02:53