简体   繁体   English

R Shiny DT :: renderDataTable卡在一个重叠的“Processing ...”横幅上

[英]R Shiny DT::renderDataTable stuck with an overlaid “Processing…” banner

My DT datatable has a banner covering it that says "Processing..." even though the data table has been processed and the data is appearing behind the banner. 即使已经处理了数据表并且数据显示在横幅后面,我的DT数据表也有一个覆盖它的横幅,上面写着“正在处理...”。 The banner won't DISAPPEAR and it's making me nuts. 横幅不会消失,它让我疯狂。

愚蠢的F%&*处理横幅

Certain users of my App WANT the column-specific search functionality of the deprecated shiny::renderDataTable() so I am running the shiny::renderDataTable() for data.frames on some tabs, and the DT::renderDataTable() on other tabs. 我的应用程序的某些用户想要使用已弃用的shiny :: renderDataTable()的列特定搜索功能,所以我在某些选项卡上运行了data ::frames的shiny :: renderDataTable(),而在其他选项卡上运行了DT :: renderDataTable()标签。

I'm using R-Portable (Windows 7) because the app needed to be deployable to relevant stakeholders on the floor... so unless you're using R-Portable, I don't believe you'll fully reproduce the environment I'm running... but this seems like an AJAX problem, so maybe someone with insight can give an answer without "reproducing" the error. 我正在使用R-Portable(Windows 7),因为应用程序需要部署到地板上的相关利益相关者...所以除非你使用R-Portable,否则我不相信你会完全重现环境我正在运行...但这看起来像是一个AJAX问题,所以也许有洞察力的人可以在没有“再现”错误的情况下给出答案。 Besides, there's at least 1500 lines of code in this Shiny App, so I'm pulling out what I can to elucidate the question without leaving too much confusion. 此外,这个Shiny App中至少有1500行代码,所以我正在尽我所能来解释这个问题,而不会留下太多的混乱。

Everything works flawlessly in my app in terms of functionality... and I'm using all of the following packages including shinyBS (bootstrap) and shinythemes, setting all major functions into the global.R file: 在功能方面,我的应用程序中的所有功能都完美无缺......我正在使用以下所有软件包,包括shinyBS(bootstrap)和闪亮主题,将所有主要功能设置为global.R文件:

library(shiny)
library(shinyBS)
library(shinythemes)
library(RODBC)
library(ggplot2)
library(gridExtra)
library(Hmisc)
library(stringr)
library(data.table)
library(DT)

I create my reactive data table object with a function that calls from our SQL databases using RODBC... I've got an action button, a text input, and the reactive() script calls the function AttrInfo() which returns a data.frame. 我使用一个函数创建我的反应数据表对象,该函数使用RODBC从我们的SQL数据库调用...我有一个操作按钮,一个文本输入,而reactive()脚本调用函数AttrInfo()返回一个数据。帧。

TriInfo = reactive({
  input$UpdateTBAtt
  if(input$UpdateTBAtt == 0) return(NULL)
  isolate(withProgress(message = "Searching for Credit Attribute", 
                     value = 0, {
                       AttrInfo(input$TriAttr)
                     }))
})

My code for rendering the data table is following the DT guide: 我的渲染数据表的代码遵循DT指南:

 output$TriLDD <- DT::renderDataTable({
   req(input$UpdateTBAtt)
   DT::datatable(TriInfo(),options = list(paging=FALSE,searching=FALSE))
 })

My ui.R file calls this object: 我的ui.R文件调用此对象:

 shinyUI(fluidPage(
     list(tags$head(HTML('<link rel="icon", href="RosiePageICON.png", 
                  type="image/png" />'))),
     div(style="padding: 1px 0px; width: '100%'",
       titlePanel(title="", windowTitle="Rosetta")), 
     navbarPage(theme = shinytheme("spacelab"),title = div(img(src="ReadyRosie_Logo6.png"),""),
tabPanel("Tri-Bureau Attributes",
    sidebarLayout(
        sidebarPanel(width = 3,
            actionButton(inputId = "UpdateTBAtt",label = "Get Attribute"),
            textInput("TriAttr","Credit Attribute:", value = "")),    
        mainPanel(width=9,
            tabsetPanel(id = "TB",
                tabPanel(title = "Check Tables",
                     p("Here's the Definition:"),
                     dataTableOutput(outputId = "TriLDD")))))))))

So I finally found the workaround buried in the jQuery library... sometimes it doesn't require reproducible code if the answer is a simple option... 所以我终于找到了隐藏在jQuery库中的解决方法......如果答案是一个简单的选项,有时它不需要可重现的代码......

In general, something in the jQuery processing of the DT library when the shiny::renderDataTable command is also sourced in the same app, this is causing the issue. 一般来说,当gl :: renderDataTable命令也在同一个应用程序中获取时,在DT库的jQuery处理中出现了一些问题,这就引起了问题。 Anyway, I found a simple workaraound. 无论如何,我发现了一个简单的工作原理。

I went to the dataTables jQuery page and found the "processing" option... I just added it to the options: 我去了dataTables jQuery页面并找到了“处理”选项......我刚刚将它添加到选项中:

DT::datatable(TriInfo(),options = list(paging=FALSE, searching=FALSE, processing=FALSE)) 

and it finally disappeared. 它终于消失了。

This can occur if shiny thinks you're using shiny::dataTableOutput() instead of DT::dataTableOutput() . 如果有光泽认为你正在使用shiny::dataTableOutput()而不是DT::dataTableOutput()就会发生这种情况。

If you explicitly use DT::renderDataTable() and DT::dataTableOutput() in your server and ui you will avoid this issue. 如果在服务器和ui中明确使用DT::renderDataTable()DT::dataTableOutput() ,则可以避免此问题。

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

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