Hello guys.
I finally managed to make something like a reprex of my app. I just put the part I'm having problems with. I'm creating an app using the shinydashboard layout. I select options but I want it to only run after clicking the button. That is, I want to control reactivity. The problem is, he doesn't. I put a spiner to confirm. It runs when selecting the menu option and ignores the button. Below is my code. It doesn't have a database. Could anyone help me how can I solve the problem?
Thanks.
library(DT)
library(kableExtra)
library(knitr)
library(lubridate)
library(magrittr)
library(stringr)
library(shiny)
library(tidyverse)
head <- dashboardHeader(title = "Menu de Opções", titleWidth = 300)
side <- dashboardSidebar(width = "300px",
sidebarMenu(
menuItem("Inicio",tabName = "inicio"
),
menuItem("Tabelas Pivot", tabName = "pivot",
dateRangeInput('date_range1',
label = 'Amplitude da período: yyyy-mm-dd',
start = Sys.Date() - 61, end = Sys.Date()
),
menuSubItem("Internação",tabName = "pvt_medico"),
menuSubItem("Ambulatório",tabName = "pvt_atend"),
menuSubItem("Exames",tabName = "pvt_exames"),
actionButton("execute","Executar!!!"),
br()
)
)
)
################ Corpo do dahsboarb
body <- dashboardBody(
fluidPage(
tabItems(
tabItem(tabName = "pvt_medico",
fluidRow(
box(width = 12,height = "600px",
tags$head(tags$style( type = 'text/css', '#myPivotAM{ overflow-x: scroll; overflow-y: scroll; }')),
withSpinner(verbatimTextOutput("myPivotAM"))))
),
tabItem(tabName = "pvt_atend",
fluidRow(
box(width = 12,height = "600px",
tags$head(tags$style( type = 'text/css', '#myPivotAM{ overflow-x: scroll; overflow-y: scroll; }')),
withSpinner(verbatimTextOutput("myPivotAT"))))
),
tabItem(tabName = "pvt_exames",
fluidRow(
box(width = 12,height = "600px",
tags$head(tags$style( type = 'text/css', '#myPivotAM{ overflow-x: scroll; overflow-y: scroll; }')),
withSpinner(verbatimTextOutput("myPivotEX"))))
)
)
)
)
dashboardPage(head, side, body, skin = c("green"))
server <- function(input, output) {
observeEvent(input$execute,{
#-----------------------------------------------------------------------------
output$myPivotAM <- renderPrint({
print("Opção Internação")
print(input$date_range1)
})
#------------------------------------------------------------------------------
output$myPivotAT <- renderPrint({
print("Opção Anbulatório")
print(input$date_range1)
})
#------------------------------------------------------------------------------
output$myPivotEX <- renderPrint({
print("Opção Exames")
print(input$date_range1)
})
})
}