shinysky-如何访问textInput.typeahead()值

shinysky-如何访问textInput.typeahead()值,shiny,shinydashboard,shinyjs,shinysky,Shiny,Shinydashboard,Shinyjs,Shinysky,我找不到关于这个相当不受欢迎的包()的很多信息,但我正在使用它的自动完成功能。我可以让文本框自动完成并建议单词,但我想访问该值并将其逐字打印出来 这是我在服务器中的内容。R: library(shiny) my_autocomplete_list <- c("aaaa","bbbb","ccccc", "dddd","eeee") # ============================================================================

我找不到关于这个相当不受欢迎的包()的很多信息,但我正在使用它的自动完成功能。我可以让文本框自动完成并建议单词,但我想访问该值并将其逐字打印出来

这是我在服务器中的内容。R:

library(shiny)

my_autocomplete_list <- c("aaaa","bbbb","ccccc", "dddd","eeee")

# ============================================================================================================
# ============================================================================================================

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  output$dateRangeText  <- renderText({
    paste("input$dateRange is", 
          paste(as.character(input$dateRange), collapse = " to ")
    )
  })

  # output$CodeText <- rederText({
  #   paste("input$code is",
  #         paste(as.character(input$code)))
  # })

  output$PercentText <- renderText({
    paste("input$percent_to_invest is",
          paste(as.character(input$percent_to_invest)))
  })

  output$InvestText <- renderText({
    paste("input$money_to_invest is",
          paste(as.character(input$money_to_invest)))
  })



})
library(shiny)
library(shinysky)

shinyUI(fluidPage(

  tags$style(type="text/css",".shiny-output-error { visibility: hidden; }",".shiny-output-error:before { visibility: hidden; }"),
  tags$style(type="text/css","#search { top: 50% !important;left: 50% !important;margin-top: -100px !important;margin-left: -250px 
             !important; color: blue;font-size: 20px;font-style: italic;}"),

  sidebarLayout(
    sidebarPanel(
      dateRangeInput('dateRange',
                     label = 'Date range input: yyyy-mm-dd',
                     start = Sys.Date() - 2, end = Sys.Date() + 2
      ),

      textInput.typeahead(id="search",
                          placeholder="Type your name please",
                          local=data.frame(name=c(my_autocomplete_list)),
                          valueKey = "name",
                          tokens=c(1:length(my_autocomplete_list)),
                          template = HTML("<p class='repo-language'>{{info}}</p> <p class='repo-name'>{{name}}</p>")
      ),

      numericInput("percent_to_invest", "Percent", value = 0),

      numericInput("money_to_invest", "Intial Investment ($)", value = 0),

      select2Input("select2Input3",
                   "Multiple Select 2 Input",
                   choices = c("a","b","c"),
                   selected = c("b","a"), 
                   type = "select",
                   multiple=TRUE),

      actionButton("add", "Add+"),

      verbatimTextOutput("dateRangeText"),
      # verbatimTextOutput("CodeText"),
      verbatimTextOutput("PercentText"),
      verbatimTextOutput("InvestText"),

      actionButton("submit", "Submit")
    ),

    mainPanel(
    )
  )
))
库(闪亮)

我的自动完成列表为什么不直接使用这个
input$search
打印出来呢

你可以试试这个:

ui <- fluidPage(

  tags$style(type="text/css",".shiny-output-error { visibility: hidden; }",".shiny-output-error:before { visibility: hidden; }"),
  tags$style(type="text/css","#search { top: 50% !important;left: 50% !important;margin-top: -100px !important;margin-left: -250px 
             !important; color: blue;font-size: 20px;font-style: italic;}"),
  tags$style(HTML("
                  .input {
                  width: 50%;
                  }
                  ")),

  tags$style(HTML("
                  .tt-hint {
                  width: 50%;
                  }
                  ")),

  sidebarLayout(
    sidebarPanel(
      dateRangeInput('dateRange',
                     label = 'Date range input: yyyy-mm-dd',
                     start = Sys.Date() - 2, end = Sys.Date() + 2
      ),

      textInput.typeahead(id="search",
                          placeholder="Type your name please",
                          local=data.frame(name=c(my_autocomplete_list)),
                          valueKey = "name",
                          tokens=c(1:length(my_autocomplete_list)),
                          template = HTML("<p class='repo-language'>{{info}}</p> <p class='repo-name'>{{name}}</p>")
      ),

      numericInput("percent_to_invest", "Percent", value = 0),

      numericInput("money_to_invest", "Intial Investment ($)", value = 0),

      select2Input("select2Input3",
                   "Multiple Select 2 Input",
                   choices = c("a","b","c"),
                   selected = c("b","a"), 
                   type = "select",
                   multiple=TRUE),

      actionButton("add", "Add+"),

      verbatimTextOutput("dateRangeText"),
      # verbatimTextOutput("CodeText"),
      verbatimTextOutput("PercentText"),
      verbatimTextOutput("InvestText"),
      textOutput("testing"),

      actionButton("submit", "Submit")
    ),

    mainPanel(
    )
  )
  )


server <- function(input, output) {

  output$dateRangeText  <- renderText({
    paste("input$dateRange is", 
          paste(as.character(input$dateRange), collapse = " to ")
    )
  })

  # output$CodeText <- rederText({
  #   paste("input$code is",
  #         paste(as.character(input$code)))
  # })

  output$PercentText <- renderText({
    paste("input$percent_to_invest is",
          paste(as.character(input$percent_to_invest)))
  })

  output$InvestText <- renderText({
    paste("input$money_to_invest is",
          paste(as.character(input$money_to_invest)))
  })

  output$testing  <- renderText({
    print(input$search)
  })


}


shinyApp(ui, server)

ui您能先修复代码吗?它不起作用。@MLavoie这是完整的代码。嗯,在我发布之前,我试过它似乎不起作用,但我想它起作用了!谢谢顺便问一下,你知道如何使空白盒的尺寸变小吗?我尝试更改百分比,但没有成功。@user9532692“我编辑了您后续问题的回答。如果你能接受我的回答,我将不胜感激。谢谢