library(shiny)
library(shinyjs)
library(DT)
ui <- fluidPage(
shinyjs::useShinyjs(),
sidebarLayout(
sidebarPanel(
numericInput(inputId = "num1", "Numeric 1", value = 10),
numericInput(inputId = "num2", "Numeric 2", value = 20),
actionButton("go", "GO")
),
mainPanel()
)
)
server <- function(input, output, session) {
observe({
#The element will be enabled if the condition evaluates to TRUE
shinyjs::toggleState("go",condition = isTruthy(input$num1) && isTruthy(input$num2))
})
v1_r<- reactiveValues()
observeEvent(input$go, {
v1_r$colm1 <- input$num1
v1_r$colm2 <- input$num2
v1_r$df_check <- data.frame("Variables"=c("Input one","Input two"),"Values"=c(v1_r$colm1,v1_r$colm2))
v1_r$review = datatable(rownames=FALSE,selection = "none",options = list(dom='t',pageLength = nrow(v1_r$df_check), autoWidth = FALSE,columnDefs = list(list(width = '20%', targets = c(1)),list(className = 'dt-center',targets=c(1)))),v1_r$df_check)
showModal(
modalDialog(
footer = tagList(modalButton("Update record"),actionButton("click",label="Proceed")),
strong(em("Inputs Entered")),
p("Please double check the inputs entered before you proceed"),
DT::renderDataTable({v1_r$review})
)
)
})
observeEvent(input$click, {
#Save to CSV file
shinyjs::reset("num1");shinyjs::reset("num2")
removeModal()
})
}
shinyApp(ui,server)
Вот как я решаю эту проблему, надеюсь, это поможет;)