How to have reactive DataTable at the click of a button?

I understand there is some similiar thread related to my issue, like how to Pass reactive() data frame into reactiveValues(), but I tried, it does not work.
Basically, I need to update a certain row at a certain column (or you can say certain cell) in a dataframe, when the user clicks a button. The DataTable gets its values from this dataframe. I can see that the cell gets updated in its dataframe (inside RStudio), because when the user clicks the button, I make a statement to save that dataframe. But I need that updated values to be reflected inside my DataTable in the Shiny application too.

DailyReport_Updated <- reactive({
                       load("/srv/shiny-server/data/DailyReportUpdated.RData")
                       DailyReportUpdated
})

# init the values
DailyReportUpdated <- DailyReport_Updated()
RV <- reactiveValues(
  #DailyReportUpdated = NULL,
  data = DailyReportUpdated
)

# set RV$data whenever DailyReport_Updated updates
observe({
  RV$data <- DailyReport_Updated()
})

output$DailyReport_table <- renderDataTable(RV$data,server=TRUE,selection="single")

output$AddtoReport_Save <- renderUI({
  tagList(
    bsModal("modalSave_AddReport", "Save Report", "save_tmp_Report", size = "small",wellPanel(
      h3('Are you sure you want to Add Report?'),
      actionButton("save_AddReport", "Save"),
      actionButton("cancel_AddReport", "Cancel")
    )),
    actionButton('save_tmp_Report','Add Report')
  )
})

observeEvent(input$save_AddReport,{
  rownumber <- input$DailyReport_table_rows_selected[length(input$DailyReport_table_rows_selected)]
  
DailyReportUpdated <- DailyReport_Updated()
  
  DailyReportUpdated <- remove.factors(DailyReportUpdated)
  DailyReportUpdated[rownumber,2] <- "Draft"
  DailyReportUpdated[rownumber,3] <- "View"
  save(DailyReportUpdated,file='/srv/shiny-server/data/DailyReportUpdated.RData')
  
  toggleModal(session,'modalSave_AddReport','close')
})

For the best chance at getting meaningful help, I would recommend that you provide a reprex.

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