glin / reactable

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

Expand rows by any column, not all #314

Open bikeactuary opened 1 year ago

bikeactuary commented 1 year ago

cross-posting for visibility

I want to see column "val" according to colA and time, without expanding/seeing values of colB (value is summed over the categories within this column). But also leaving colB in the table for user to optionally expand for the finer detail. Is this possible?

dat <- data.frame(colA = c(rep("Yes", 20,), rep("No", 20)),
                  colB = rep(c(letters[1:5]), 4)) %>%
  arrange(colA, colB) %>%
  mutate(time = rep(1:4, 10),
         val = runif(40))

reactable(dat,
  groupBy = c("colA", "colB"),
  columns = list(
    val = colDef(aggregate = "sum")
  ),
  bordered = TRUE)
glin commented 1 year ago

Coincidentally, I just answered pretty much the same question in a different issue! Copying my response from https://github.com/glin/reactable/issues/268#issuecomment-1421300337:

expansion is either all or nothing right now due to prior technical limitations. I've never thought of limiting expansion to certain columns (or I guess nesting level) though, and I think that's a really great idea.

So this isn't possible right now, but I'll tag it as a feature request to look at whenever I revisit default row expansion.

bikeactuary commented 1 year ago

Thx - subscribing