glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
627 stars 80 forks source link

How to know when the selection has changed? #254

Open justacec opened 2 years ago

justacec commented 2 years ago

It is not clear from the examples and the documentation how to tell (what input to observe) when the selection has changed in a shiny app. I notice that the shiny demo for reactable somehow does it but that element of the demo code is not available to look at.

I know that selectionID used to be an input that one could watch, but that is being deprecated in favor of the get state function.

Can somebody here point me in the right direction to know what to watch for to see if the selection has changed?

glin commented 2 years ago

Have you seen the Row selection Shiny example on the Examples page? There's no live demo for that, but you can copy and run this minimal app in a console to see how you can watch the selection state and do things when rows are selected. getReactableState(tableId, "selected") is pretty much the Shiny input you'd use in an observer or Shiny output.