2017-12-26 12 views
0

동적 데이터와 함께 handsontable을 사용하고 제출 버튼이 반짝이는 sqlSave 코드로 MSSQL DB에 업로드하고 있습니다.SQL DB로 데이터를 내보내는 동안 x 초 동안 동작 버튼을 사용하지 못하게 함

그러나 액션 버튼을 사용할 수 없게 만드는 기능을 찾을 수있어 10 초가 소요될 수 있습니다. shinyjs :: disable 및 withProgress, incProgress 일을 시도했지만 그들 중 누구도 일하지 않았습니다.

당신이 비활성화를 통합하고 이전 활성화 및 행동 기능 후에 때 똑바로 앞으로 더 이하의

dbhandle <- odbcDriverConnect('driver={SQL Server};server=....;database=...;trusted_connection=true') 

withProgress( 
sqlSave(dbhandle, dat = some data), 
     tablename = "Budget_Tool", 
     rownames = F, append = T, verbose = T, fast = F, colnames = F, safer = 
     T), value = 1, 
     style = "notification", message = "Submitting, please wait..") 

    -------------------- 
     actionButton("submit", "Submit", class = "btn-primary", 
        style="color: #fff; background-color: #337ab7; border- 
     color: #2e6da4; font-size: 20px;"), 

답변

0

내가 숨기기와 쇼를 사용하여 고정;

observeEvent(input$submit, { 
    hide('submit', animType = "fade", time = 5) 
asd <- as.data.frame(cbind(Department = rv$data[,2], Cost_Summary_Key = 
    rv$data[,1], Calculated_Budget = rowSums(rv$data[,3:14]))) %>% 
    left_join(CSK_Budget, c("Department", "Cost_Summary_Key")) 

    asd <- asd %>% mutate(Deviation = (as.numeric(Budget_2017) - rowSums(rv$data[,3:14]))) 

    x <- c() 

    for (i in 1:nrow(asd)) { 

    if(asd[i,5] >= -0.05) 
    {x[i] <- TRUE} else {x[i] <- FALSE} 

} 

moment <- substr(Sys.time(), 1, 10) 
moment2 <- substr(Sys.time(), 12, 19) 
personel <- input$userName 


if(all(x)) 
{ 


    dbhandle <- odbcDriverConnect('driver={SQL Server};server=...;database=...._SQL;trusted_connection=true') 

    withProgress( 
    sqlSave(dbhandle, dat = (cbind(melt(rv$data, na.rm = F, varnames = c(Department, Cost_Summary_Key), as.is = F), Year = "2017", 
            Time_Stamp1 = moment, Time_Stamp2 = moment2, User = personel)), 
      tablename = ".....", 
      rownames = F, append = T, verbose = T, fast = F, colnames = F, safer = T), value = 1, 
    style = "notification", message = "Submitting, please wait..") 


    js_string <- 'alert("Succes!!");' 
    session$sendCustomMessage(type='jsCode', list(value = js_string)) 
    showNotification("Thanks, your response was submitted successfully!", duration = 5, type = "warning") 
} 
else {showNotification("Check Your Budget Items !!", duration = 3, type = "warning")} 

odbcCloseAll() 
show('submit', animType = "slide", time = 1) 
    }) 
1

, 감사합니다. 여기

은 샘플 코드 조각입니다 :

library(shiny) 
library(shinyjs) 

ui <- shinyUI({ 
    shiny::fluidPage(
    useShinyjs(), # Set up shinyjs 
    actionButton(inputId = "start", label = "start") 
) 
}) 

server <- shinyServer(function(input, output){ 
    actionFunction = function(){ 
    shinyjs::disable("start") 

    # Replace actual code instead 
    withProgress(message = 'Calculation in progress', 
       detail = 'This may take a while...', value = 0, { 
        for (i in 1:15) { 
        incProgress(1/15) 
        Sys.sleep(0.25) 
        } 
       }) 

    shinyjs::enable("start") 
    } 

    # Run action function on button click 
    onclick("start", actionFunction()) 
}) 

shinyApp(ui,server) 
+0

불행히도 작동하지 못했습니다. –