Is there a way I can make an action button reactive inside the server function to display an output?

Viewed 30

I am developing a shiny app, where I want my action button to be created and be reactive from the server part of my code and show an output.

My current code looks like:

ui <- fluidPage(
  tags$head(
    tags$style(HTML("
      body {
      background-color: #black
      }"))),br(),
  titlePanel(h1("Query Engine", align = 'Center')),br(),
  #helpText("", align='Center'),
  sidebarLayout(
    sidebarPanel( width = 3,
                  sliderInput("amnt", label='Amount (USD)',
                              min= as.integer(min(df$gross_amount))-1, max=as.integer((max(df$gross_amount)))+1, #subtract/add 1 cuz cutting off the cents
                              value = c(min(df$gross_amount),max(df$gross_amount)), step = 0),
                  
                  uiOutput("date"), #input#1
                  uiOutput("customer"), #input#2
                  uiOutput("id"), #input#3
                  actionButton("btn","Summary", width = '100%'), br()
    ),

mainPanel(
     tabPanel("1", value = "check1", DT::dataTableOutput("table_subset1")),
tabPanel("2", value = "check2", DT::dataTableOutput("table_subset2"))

)
      
    )
  )
)
#################  Server_Part ################# 
 df$Check_Name[df$check_id==1 ]<- data.table(as.character(actionButton("btn1","Creation")))


  submit1 <- eventReactive(input$btn1,{
    idfilter <- df_filtered1()[ , c('id','company','code','amount','gst', 'hst_amount','currency')]
  })
  
  # this is the output which we are showing:
  output$table_subset1 <- DT::renderDataTable({
    DT::datatable(distinct(submit1()), options = list(scrollX = T))
  })

 observeEvent(input$btn1, {updateTabsetPanel(session, "tabset1", selected = "check1")})

This is just a dummy code and dummy data, the main thing is that my action button is appearing successfully but its not reactive. Can someone please help me figure out what wrong am i doing?

This is a picture of the output:

enter image description here

As can be seen the action button gets created but it's not reactive.

0 Answers
Related