Question
How to show a ConditionalPanel when a row in a reactable table is selected?
I have a reactable
data table containing mtcars
and would like to show a table containing iris
on the UI
only when a row in the mtcars
table is selected.
The below condition
is not working.
library(shiny)
library(reactable)
library(DT)
server <- function(input, output) {
# Reactable data table
output$dt_mtcars <- renderReactable({
mtcars %>%
reactable(
selection = "single",
defaultSelected = c(),
onClick = "select"
)
})
# Reactable data table
output$dt_iris <- renderDataTable({
iris
})
}
ui <- fluidPage(
conditionalPanel(
condition = "input.dt_mtcars_selected !== null && input.dt_mtcars_selected.length > 0",
dataTableOutput("dt_iris")),
reactableOutput("dt_mtcars")
)
shinyApp(ui, server)
3 39
3