我正在尝试使用Shiny创建一个表格,用户可以单击行以查看有关该行的更多信息。我认为我理解如何做到这一点(请参见附加的代码)。
然而,现在当用户点击“getQueue”操作按钮时,似乎会调用observeEvent(input$fileList_cell_clicked, {})。为什么在用户甚至没有机会单击行之前就会调用它呢?生成表格时也会调用它吗?有没有办法避免这种情况?
我需要替换“output$devel <- renderText(”cell_clicked_called“)”的代码,如果没有实际单元格可引用,它将出现各种错误。
感谢您的任何建议!
然而,现在当用户点击“getQueue”操作按钮时,似乎会调用observeEvent(input$fileList_cell_clicked, {})。为什么在用户甚至没有机会单击行之前就会调用它呢?生成表格时也会调用它吗?有没有办法避免这种情况?
我需要替换“output$devel <- renderText(”cell_clicked_called“)”的代码,如果没有实际单元格可引用,它将出现各种错误。
感谢您的任何建议!
ui <- fluidPage(
actionButton("getQueue", "Get list of queued files"),
verbatimTextOutput("devel"),
DT::dataTableOutput("fileList")
)
shinyServer <- function(input, output) {
observeEvent(input$getQueue, {
#get list of excel files
toTable <<- data.frame("queueFiles" = list.files("queue/", pattern = "*.xlsx")) #need to catch if there are no files in queue
output$fileList <- DT::renderDataTable({
toTable
}, selection = 'single') #, selection = list(mode = 'single', selected = as.character(1))
})
observeEvent(input$fileList_cell_clicked, {
output$devel <- renderText("cell_clicked_called")
})}
shinyApp(ui = ui, server = shinyServer)