Is it possible to ask in condition
within conditionalPanel
whether the input of a selectedInput
belongs to a vector.
It is clear to me that condition
is a JavaScript
object and here is a similar problem here. However, my problem is a littel bit different.
I made a simple example:
# ----
library(shiny)
library(shinydashboard)
var array1 = ['a','c', 'f'];
# header ----
header <- dashboardHeader(title = "Example")
#sidebar ----
sidebar <- dashboardSidebar(disable = T)
#body ----
body <- dashboardBody(
fluidRow(
column(
width = 12,
selectInput(
inputId = "control",
label = "choose something:",
choices = c("a",
"b",
"c",
"d",
"e",
"f"),
multiple = TRUE
)
)
),
conditionalPanel(
condition = "input.control.indexOf(array1) > -1",
textInput(inputId = "first", label = "first test")
)
)
# all ui ----
ui <- dashboardPage(
header = header,
sidebar = sidebar,
body = body
)
# server ----
server = shinyServer(function(input, output) {
})
# Run the application
shinyApp(ui = ui, server = server)
I defined an js-array
var array1 = ['a','c', 'f'];
however it dose not work. Any idea?