微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我可以在 R 中使用 observeEvent 创建提交按钮吗?

如何解决我可以在 R 中使用 observeEvent 创建提交按钮吗?

当我想创建提交按钮时,我只是停留在 observeEvent 中,当我点击时,该事件不会执行任何操作,例如我的模态代码

column(width = 6,bs4Card(width = 12,collapsible = FALSE,title = "Follow Up",selectInput("cara_fu","Cara Follow up",choices = c('Call','Whatsapp','Visit')),selectInput("hasil_fu","Hasil Follow up",choices = c('Survey','Batal','Unreachable')),textAreaInput("ket_fu","Keterangan",height = '100px'),footer = actionButton("submit_fu","Submit",status = "success")
 )
)

然后当表单被值输入时,observeEvent 将由此代码生成

    # IF USER CLICKS SUBMIT FOLLOWUP,SAVE THE DATA IN DATABASE
  observeEvent(input$submit_fu,{
        text = tagList(
        selectInput("cara_fu",'Visit'),selected = df$cara_fu),'Unreachable'),selected = df$hasil_fu),textInput("ket_fu","Keterangan")
               )
  }) # End observe submit button 

当这个按钮没有任何反应时,我很高兴你们都能在这里找到问题所在,谢谢

这里是完整的代码

shiny::observeEvent(input$current_id,{
shiny::req(!is.null(input$current_id) &
             stringr::str_detect(input$current_id,pattern = "followup"
             ))
rv$dt_row <- which(stringr::str_detect(rv$df$Buttons,pattern = paste0("\\b",input$current_id,"\\b")
))
showModal(
  modalDialog(title = "Followup",easyClose = TRUE,size = "l",fluidPage(
                fluidRow(
                  column(width = 6,title = "Profile Summary",BoxProfile(
                                   image = "https://adminlte.io/themes/AdminLTE/dist/img/user4-128x128.jpg",title = (rv$df$nama_customer[rv$dt_row]),subtitle =(rv$df$no_hp_customer[rv$dt_row]),bordered = TRUE,BoxProfileItem(
                                     title = "Jadwal Followup",description =rv$df$scheduled_followup[rv$dt_row]),BoxProfileItem(
                                     title = "Produk",description = rv$df$produk[rv$dt_row]),BoxProfileItem(
                                     title = "Status",description = rv$df$status[rv$dt_row])
                                 )
                         ),title = "History Followup",timelineBlock(
                                   width = 12,timelineLabel(as.Date(Sys.Date()),color = "primary"),timelineItem(
                                     title = "Followup 1",icon = icon("book"),color = "secondary",time = "Now","This is the body"
                                     ),timelineItem(
                                     title = "Followup 3",color = "secondary"
                                     )
                                   )
                                 )
                         ),column(width = 6,status = "success")
                                 )
                         )
                )
              ),footer = tagList(
                modalButton("Cancel"),actionButton("ok","OK")
                )
              )
  )
 observeEvent(input$submit_fu,{
               text = tagList(
                 selectInput("cara_fu","Keterangan")
               )
      }) # End observe submit button 
  }) # End observe followup button
}
# Run the application
shinyApp(ui = ui,server = server)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。