首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >radioButtons上SelectInput中的Switch 2列表

radioButtons上SelectInput中的Switch 2列表
EN

Stack Overflow用户
提问于 2017-11-18 21:05:44
回答 2查看 191关注 0票数 0

如何根据selectInput选择将2个列表(fooChoices1和fooChoices2)切换为radioButton?

另外,是否有可能阻止SelectInput中的字符输入,使其只有列表选项(因为我在此选项上驱动了一个SQL查询)?

谢谢你的帮助

这是我的UI.R:

代码语言:javascript
复制
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")
   ))

代码语言:javascript
复制
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")
EN

回答 2

Stack Overflow用户

发布于 2017-11-19 03:47:17

您可以在服务器功能中使用observeEvent来完成切换

代码语言:javascript
复制
observeEvent({
    input$base
  },
  {
    if(input$base == "base-1"){
      updateSelectInput(
        inputId = "cible",
        choices = fooChoices1, 
        selected = "ALL"
      )
    } else {
      updateSelectInput(
        inputId = "cible",
        choices = fooChoices2, 
        selected = "ALL"
      )
    }
  })

关于你的第二个问题:如果我理解正确的话,实际上没有必要阻止文本输入-当你有很多选择时,这只是一个搜索工具-用户仍然被限制在参数选择中定义的选择。

票数 0
EN

Stack Overflow用户

发布于 2017-11-19 04:50:34

我试着用observeEvent,但它不起作用,闪亮的退出

我发现这一点:

代码语言:javascript
复制
output$cible <- renderUI({

 if(input$base == "base-1")
selectInput("cible", "Select test:", 
                       choices = fooChoices1)
else 
  selectInput("cible", "Select test:", 
             choices = fooChoices2)



 })

在UI.R中使用

代码语言:javascript
复制
   uiOutput("cible"),
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47366428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档