Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny DT::renderDataTable stuck with an overlaid "Processing..." banner

Tags:

r

dt

shiny

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. The banner won't DISAPPEAR and it's making me nuts.

Stupid F%&*ing Processing Banner

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.

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. 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.

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:

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.

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:

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

My ui.R file calls this object:

 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")))))))))
like image 930
quickreaction Avatar asked Jun 16 '16 14:06

quickreaction


2 Answers

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...

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. 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:

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

and it finally disappeared.

like image 111
quickreaction Avatar answered Nov 13 '22 15:11

quickreaction


This can occur if shiny thinks you're using shiny::dataTableOutput() instead of DT::dataTableOutput().

If you explicitly use DT::renderDataTable() and DT::dataTableOutput() in your server and ui you will avoid this issue.

like image 41
SymbolixAU Avatar answered Nov 13 '22 15:11

SymbolixAU