r-observeEvent或eventReactive工作不正常.我用它只在点击按钮时显示表格.孤立不工作,除非我错了


server <- function(input, output) {
observe({
# check if all mandatory fields have a value
mandatoryFilled <-
vapply(fieldsMandatory,
function(x) {
!is.null(input[[x]]) && input[[x]] != ""
},
logical(1))
mandatoryFilled <- all(mandatoryFilled)
# enable/disable the submit button
shinyjs::toggleState(id = "btn", condition = mandatoryFilled)
observeEvent(input$btn, {
output$inventory <- renderDataTable(result[result$lot == input$lot, ])
})
})
}

我试着隔离它不起作用,我不确定我做得是否正确。eventReactive和observeEvent都不能正常工作。请有人帮我弄清楚。input$lot是来自用户的输入,该输入用于显示数据表中的信息。

server <- function(input, output) {
observe({
# check if all mandatory fields have a value
mandatoryFilled <-
vapply(fieldsMandatory,
function(x) {
!is.null(input[[x]]) && input[[x]] != ""
},
logical(1))
mandatoryFilled <- all(mandatoryFilled)
# enable/disable the submit button
shinyjs::toggleState(id = "btn", condition = mandatoryFilled)
observeEvent(input$btn, {
output$inventory <- renderDataTable(result[result$lot == input$lot , ])
})
})
}

相关内容

最新更新