简体   繁体   English

R Shiny 仅在单击操作按钮后渲染数据表

[英]R Shiny only renderDataTable after actionbutton clicked

I want the user to click a button and then the renderDataTable function gets called我希望用户单击一个按钮,然后调用 renderDataTable 函数

This is what I'm doing now:这就是我现在正在做的:

The UI has this:用户界面有这个:

ui <- fluidPage(
 actionButton("tbl","Show Table"),
 DT::dataTableOutput("t_all")
)

Server:服务器:

server <- function(input, output){

summary_table_RCT <- eventReactive(input$tbl, {summary_table})

output$t_all <-
DT::renderDataTable(
  summary_table_RCT(), 
  filter = 'top',
  class = "cell-border stripe",
  rownames = FALSE,
  extensions = c("FixedColumns"),
  options = list(searchHighlight = TRUE, 
                 regex = TRUE,
                 scrollX = TRUE,
                 fixedColumns = list(leftColumns = 5)) 
)
}

shinyApp(ui, server)

Not sure why it's not working this is almost the same as some of the examples I've seen for eventReactive().不知道为什么它不起作用,这与我看到的 eventReactive() 的一些示例几乎相同。 I see the button show up, but it doesn't do anything when clicked.我看到按钮显示出来,但单击时它没有做任何事情。

Found the answer, hopefully someone who has to go through the same frustration finds this before it makes them nuts.找到了答案,希望那些不得不经历同样挫折的人在这让他们发疯之前发现这一点。 But in a different tab in the app, another developer used a submitButton(), which basically interrupts ALL reactive events until the button is pressed.但是在应用程序的另一个选项卡中,另一位开发人员使用了 submitButton(),它基本上会中断所有反应性事件,直到按下按钮。 Should only only be used in very simple apps, where you only have one button.应该只用于非常简单的应用程序,在那里你只有一个按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM