R闪亮:在呈现表时显示“加载...”消息 [英] R shiny: display “loading…” message while table is being rendered

查看:153
本文介绍了R闪亮:在呈现表时显示“加载...”消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Rstudio Shiny中,我收到了一些通过RMySQL从数据库获取信息的 renderDataTable 调用。一些查询可能需要几秒钟才能完成,我想添加一个加载...消息,其中表将在等待时最终呈现。

In Rstudio Shiny, I got some renderDataTable calls that fetch information from a database via RMySQL. Some of the queries may take a few seconds to complete, and I would like to add a "Loading..." message where the table is going to finally render while waiting.

这个问题类似于这个:
R闪亮:显示加载...功能正在运行时的消息

This question is similar to this one: R shiny: display "loading..." message while function is running

但不是使用 $('html')hasClass('shiny-busy')作为条件,我想以某种方式对 renderDataTable 呈现的状态进行调整。

But instead of using $('html').hasClass('shiny-busy') as a condition, I would like to somehow condition on the status of the renderDataTable rendering.

任何想法?

推荐答案

寻找重新计算

ui <- fluidPage(
    actionButton('reload', 'reload'),
    dataTableOutput('dtable_out'),
    conditionalPanel("$('#dtable_out').hasClass('recalculating')", 
        tags$div('Loading ... ')
    )
)

server <- function(input, output, session) {

    output$dtable_out <- renderDataTable({
        input$reload
        Sys.sleep(2)
        data.frame(a=1:10, b=letters[1:10])
    })

}

runApp(list(ui=ui, server=server))

这篇关于R闪亮:在呈现表时显示“加载...”消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆