R Shiny DT::renderDataTable 卡在重叠的 "Processing..." 横幅上
R Shiny DT::renderDataTable stuck with an overlaid "Processing..." banner
我的 DT 数据table 有一个横幅覆盖它,上面写着 "Processing...",即使数据 table 已经被处理并且数据出现在横幅后面。横幅不会消失,这让我抓狂。
我的应用程序的某些用户想要已弃用的 shiny::renderDataTable() 的列特定搜索功能,所以我 运行 shiny::renderDataTable() 用于 data.frames一些选项卡,以及其他选项卡上的 DT::renderDataTable()。
我正在使用 R-Portable (Windows 7) 因为该应用程序需要可部署给现场的相关利益相关者...所以除非您使用 R-Por table,我不相信你会完全重现我运行的环境...但这似乎是一个AJAX问题,所以也许有识之士可以给出答案没有 "reproducing" 错误。此外,这个 Shiny App 中至少有 1500 行代码,因此我将尽我所能来阐明问题,而不会留下太多混乱。
就功能而言,我的应用程序中的一切都完美无缺...我正在使用以下所有软件包,包括 shinyBS (bootstrap) 和 shinythemes,将所有主要功能设置到 global.R 文件:
library(shiny)
library(shinyBS)
library(shinythemes)
library(RODBC)
library(ggplot2)
library(gridExtra)
library(Hmisc)
library(stringr)
library(data.table)
library(DT)
我创建了我的响应式数据 table 对象,其中包含一个使用 RODBC 从我们的 SQL 数据库调用的函数...我有一个操作按钮、一个文本输入和响应式( ) 脚本调用函数 AttrInfo() which returns a data.frame.
TriInfo = reactive({
input$UpdateTBAtt
if(input$UpdateTBAtt == 0) return(NULL)
isolate(withProgress(message = "Searching for Credit Attribute",
value = 0, {
AttrInfo(input$TriAttr)
}))
})
我渲染数据的代码 table 遵循 DT 指南:
output$TriLDD <- DT::renderDataTable({
req(input$UpdateTBAtt)
DT::datatable(TriInfo(),options = list(paging=FALSE,searching=FALSE))
})
我的 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")))))))))
所以我终于找到了隐藏在 jQuery 库中的解决方法...如果答案是一个简单的选项,有时它不需要可重现的代码...
一般来说,当 shiny::renderDataTable 命令也在同一个应用程序中获取时,DT 库的 jQuery 处理中的某些内容会导致此问题。无论如何,我找到了一个简单的解决方法。
我转到数据表 jQuery 页面并找到了 "processing" 选项...我只是将它添加到选项中:
DT::datatable(TriInfo(),options = list(paging=FALSE, searching=FALSE, processing=FALSE))
终于消失了
如果 shiny 认为您使用的是 shiny::dataTableOutput()
而不是 DT::dataTableOutput()
,就会发生这种情况。
如果您在服务器中明确使用 DT::renderDataTable()
和 DT::dataTableOutput()
并且 ui 您将避免此问题。
我的 DT 数据table 有一个横幅覆盖它,上面写着 "Processing...",即使数据 table 已经被处理并且数据出现在横幅后面。横幅不会消失,这让我抓狂。
我的应用程序的某些用户想要已弃用的 shiny::renderDataTable() 的列特定搜索功能,所以我 运行 shiny::renderDataTable() 用于 data.frames一些选项卡,以及其他选项卡上的 DT::renderDataTable()。
我正在使用 R-Portable (Windows 7) 因为该应用程序需要可部署给现场的相关利益相关者...所以除非您使用 R-Por table,我不相信你会完全重现我运行的环境...但这似乎是一个AJAX问题,所以也许有识之士可以给出答案没有 "reproducing" 错误。此外,这个 Shiny App 中至少有 1500 行代码,因此我将尽我所能来阐明问题,而不会留下太多混乱。
就功能而言,我的应用程序中的一切都完美无缺...我正在使用以下所有软件包,包括 shinyBS (bootstrap) 和 shinythemes,将所有主要功能设置到 global.R 文件:
library(shiny)
library(shinyBS)
library(shinythemes)
library(RODBC)
library(ggplot2)
library(gridExtra)
library(Hmisc)
library(stringr)
library(data.table)
library(DT)
我创建了我的响应式数据 table 对象,其中包含一个使用 RODBC 从我们的 SQL 数据库调用的函数...我有一个操作按钮、一个文本输入和响应式( ) 脚本调用函数 AttrInfo() which returns a data.frame.
TriInfo = reactive({
input$UpdateTBAtt
if(input$UpdateTBAtt == 0) return(NULL)
isolate(withProgress(message = "Searching for Credit Attribute",
value = 0, {
AttrInfo(input$TriAttr)
}))
})
我渲染数据的代码 table 遵循 DT 指南:
output$TriLDD <- DT::renderDataTable({
req(input$UpdateTBAtt)
DT::datatable(TriInfo(),options = list(paging=FALSE,searching=FALSE))
})
我的 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")))))))))
所以我终于找到了隐藏在 jQuery 库中的解决方法...如果答案是一个简单的选项,有时它不需要可重现的代码...
一般来说,当 shiny::renderDataTable 命令也在同一个应用程序中获取时,DT 库的 jQuery 处理中的某些内容会导致此问题。无论如何,我找到了一个简单的解决方法。
我转到数据表 jQuery 页面并找到了 "processing" 选项...我只是将它添加到选项中:
DT::datatable(TriInfo(),options = list(paging=FALSE, searching=FALSE, processing=FALSE))
终于消失了
如果 shiny 认为您使用的是 shiny::dataTableOutput()
而不是 DT::dataTableOutput()
,就会发生这种情况。
如果您在服务器中明确使用 DT::renderDataTable()
和 DT::dataTableOutput()
并且 ui 您将避免此问题。