I am creating a table in R using {reactable}.
The data I am using is grouped by Species
I would like that when I expand the group row, that I get details for the GROUP.
The examples in the {reactable} documentation only show how to provide details by ROW index.
How could I target the GROUP rather than the row?
Thanks for the help.
Here is an example:
library(dplyr)
iris2 <- iris %>%
mutate(
group_info = case_when(
Species == "setosa" ~ "Info about the setosa group",
Species == "versicolor" ~ "Info about the versicolor group",
Species == "virginica" ~ "Info about the virginica group"
)
) %>%
group_by(Species)
reactable(iris2, groupBy = "Species", details = colDef(
name = "More",
# i need to use the GROUP index, not the ROW index, however not sure how to implement this, would like the group_info to show on clicking/expanding the group
details = JS("function(rowInfo) {
return 'Details for row: ' + rowInfo.index +
'<pre>' + JSON.stringify(rowInfo.row, null, 2) + '</pre>'
}"),
html = TRUE,
width = 60
))