I'm pulling a list from a DB and trying to update that list based on search results in Shiny. I've referred to a few answers here on SO but I haven't been able to get it to work correctly. Here's my code:
ui.R
library(shiny)
library(RODBC)
library(plyr)
library(magrittr)
cxn <- odbcConnect("DSN", uid = "myID", pwd = "myPWD")
showList <- sqlQuery(cxn, "my query string", believeNRows=FALSE) %>% arrange(., SERIES_NAME) %>% .[ ,1] %>% as.character(.)
shinyUI(fluidPage(
# Application title
titlePanel("Select Show Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
textInput("nameSearch", "Search by show name"),
br(),
submitButton("Search"),
br(),
selectInput("showDrop", "Select Show", showList)
),
# Show a plot of the generated distribution
mainPanel(
)
)
))
server.R
library(shiny)
shinyServer(function(input, output, session) {
searchResults <- reactive({
showList[grepl(input$nameSearch, showList, ignore.case = TRUE)]
})
observeEvent(input$Search, function() {
output$searchResults <- renderTable({
searchResults()
})
updateTextInput(session, "showDrop", "Select Show", searchResults())
})
})
What am I missing here?