observeEvent refresh for searchInput

Hi guys, first sorry for bad English and thank you for the help!
Secondly, this issue is driving me crazy. I'm trying to send an alert when "search input" has no results because it doesnt match with my database, with shinyalert() command and it works pretty fine.
The problem is that I cant make it send another alert when I hit the Search button with the same input condition. It just do nothing, and I know its due the command observeEvent which only supports one event at time.
I know its a really no big deal problem, but I must resolve it before this quarentine ends :smiley:.

%not_in% <- purrr::negate(%in%)
ui <- shinydashboard::dashboardPage(
dashboardBody(
tabItems(
tabItem( tabName = "profile", h2("DATA"), useShinyalert(),
searchInput(inputId = "search_client", label = "Client",btnSearch= icon("search"))

server <- function(input, output, session) {

observeEvent(input$search_cliente , {
if (input$search_cliente %not_in% DASH$passport) {
shinyalert("Client no found","Check again", type = "warning", closeOnClickOutside = TRUE) }}, ignoreInit = TRUE)

output$res <- renderReactable ({
req((input$search_client %in% DASH$passport)==TRUE)
tabla_res <- reactable(filteredData_C())
})
}

shinyApp(ui, server)

Thank you again!

Konstantin

I think you have typos because sometimes its _client and others _cliente you need to be perfectly consistent.

From the documentation:
The two buttons ('search' and 'reset') act like actionButton , you can retrieve their value server-side with input$<INPUTID>_search and input$<INPUTID>_reset .

1 Like

Thanks a lot!

I came around with a no perfect solution but at least it refreshes the search input and then the alert. I use the updateSearchInput command and leave the value as empty: "".

observeEvent(input$search_cliente , {
if (input$search_cliente %not_in% DASH$Nro_Documento) {
shinyalert("Client not found","Check again", type = "warning", closeOnClickOutside = TRUE)
updateSearchInput(session = session, inputId = "search_client",
value = "", trigger = input$search_client)}
}, ignoreInit = TRUE)

I hope its useful for anyone else.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.