glin / reactable

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

how to use one table row selection result to update other tables. #343

Open secondbookwormai opened 8 months ago

secondbookwormai commented 8 months ago

I have 4 tables, table A, table B, table C, table D. the user can filter any one of 4 tables. For example, the user filter Table B first, by select gender = 'Male", then I would like to update all three other tables with information only males. (gender is a variable in Table B) then the user look at the table C, filtering Table C by country = "USA", then I would like table A, B, D are updated with gender = Male and country = USA. (country is a variable in Table C) then the user go to table D ( table D only have information about gender = MALE and country = USA), filter the table D by Degree = PHD, (degree is a variable in Table D). any idea to do it ? I am trying to use reactivevalues to keep all updated tables in each step.

glin commented 8 months ago

Hi, the general way to do this would be to use the reactive row selection state from one table, e.g. getReactableState("table", "selected"), and use that to update a different table's selection state using updateReactable(). Here are some doc examples on both:

I couldn't quite understand your example, so I think it'd help if there was some example code if you had any (even if it doesn't work yet).