如何根据selectInput选择将2个列表(fooChoices1和fooChoices2)切换为radioButton?
另外,是否有可能阻止SelectInput中的字符输入,使其只有列表选项(因为我在此选项上驱动了一个SQL查询)?
谢谢你的帮助
这是我的UI.R:
shinyUI(pageWithSidebar(
headerPanel("Measures"),
sidebarPanel(
radioButtons("base", "Select DB",
c("base1"="base-1","base2"="base-2")),
selectInput("cible", "Select le test:",
choices = fooChoices, selected = "ALL"),
),
mainPanel(
plotlyOutput("plot")
))fooChoices1<-c("ALL" = "00 00%",
"SPEC2" = "00 00297",
"SPEC3" = "00 00323",
"SPEC4" = "00 00362",
"SPEC5" = "00 00366",
"SPEC6" = "00 00399"
)
fooChoices2<-c("ALL" = "00 00%",
"SPEC2" = "00 00297",
"SPEC3" = "00 00323",
"SPEC4" = "00 00362",
"SPEC5" = "00 00366",
"SPEC6" = "00 00399")发布于 2017-11-19 03:47:17
您可以在服务器功能中使用observeEvent来完成切换
observeEvent({
input$base
},
{
if(input$base == "base-1"){
updateSelectInput(
inputId = "cible",
choices = fooChoices1,
selected = "ALL"
)
} else {
updateSelectInput(
inputId = "cible",
choices = fooChoices2,
selected = "ALL"
)
}
})关于你的第二个问题:如果我理解正确的话,实际上没有必要阻止文本输入-当你有很多选择时,这只是一个搜索工具-用户仍然被限制在参数选择中定义的选择。
发布于 2017-11-19 04:50:34
我试着用observeEvent,但它不起作用,闪亮的退出
我发现这一点:
output$cible <- renderUI({
if(input$base == "base-1")
selectInput("cible", "Select test:",
choices = fooChoices1)
else
selectInput("cible", "Select test:",
choices = fooChoices2)
})在UI.R中使用
uiOutput("cible"),https://stackoverflow.com/questions/47366428
复制相似问题