Using TextInput to filter Data Table in R Shiny

Viewed 15

Is there a way to use a textinput field to filter a DTedit table in Shiny? I realize that users could just use the search, but I'm hoping to use the textinput in multiple places so entering the information once would be more efficient. Here is my example code:

library(tidyverse)
library(shiny)
library(DT)


d<- data.frame(
  Seassion = c('Session 1', 'Session 2', 'Session 3', "Session 4", "Session 5"),
  Completed = c("Not Complete", "Not Complete", "Not Complete", "Not Complete", "Not Complete"),
  ID = c("1", "2", "3", "4", "5"),
  stringsAsFactors = FALSE
)

server <- function(input, output) {

  Grocery_List_Results <- dtedit(
    input, output,
    name = 'Grocery_List',
    thedata = d, 
    
    datatable.call = function(...) {
      DT::datatable(...) %>%
      DT::formatStyle(1:3, color = styleEqual(c("Not Complete", "Complete"), c("red", "green")))
      # note, none of this is proper formatting for the mtcars data!
      # but serves to demonstrate the formatting
    }
 
  

  

  

  )}


ui <- fluidPage(
  h3('Session Tracking'),
  textInput("ID", "ID"),
  uiOutput('Grocery_List')
)



shinyApp(ui = ui, server = server)
#> Warning in get_current_theme(): This functionality requires shiny v1.6 or higher```
0 Answers
Related