0

For my shiny app, I am using a pickerInput. When "deselect all" is selected, the output of my datatable shows an error. I am looking to print a string that says " Make sure to select an option!" when deselect all is selected. Do I have to use observeEvent, or can I use an if statement in my server code?

Here is an example of the pickerInput code: pickerInput("type", "Select Option", choices = c("a","b","c", "d"), selected = c("a","b","c","d"), options = list('actions-box' = TRUE), multiple = T)

Here is an example of the server code: output$one<- DT::renderDT({DT::datatable(caption = "table", options = list(pageLength = 50),tab1<- rbind(red, blue,green, yellow)%>% filter(num> .450, letter == input$type))

natguy8
  • 41
  • 6
  • Try looking at validate: https://www.rdocumentation.org/packages/shiny/versions/1.7.1/topics/validate – anorlondo Jun 22 '22 at 03:54
  • Please provide a minimal *reproducible* example. – Limey Jun 22 '22 at 07:11
  • @Limey In my pickerInput, when I click "Deselect All", the output area where My DT::datatable usually is says "Error[Error]". Instead, when I click "Deselect All", I want it to say "Choose an option". – natguy8 Jun 22 '22 at 22:54

1 Answers1

0

If error you can hide the datatable or return NULL and display a message via shinyalert.

JamBelg
  • 60
  • 5