1

I want to generate a boxPlus around my DT-Output. Now when I start my APP, the frame of the box is already there. How do I manage that the box is only displayed when the tableoutput is finished? As input I use a text input.

In my UI I use for the Input:

textInput("name", "Insert Number:")

the final box I create with:

uiOutput("box")

On Serverside I do:

output$name <- renderText(input$name)

  New_input <- reactive({
    list(input$name)
  })

and the box I create like this:

output$box <- renderUI({
    boxPlus(
      div(style = 'overflow-x: scroll;'), dataTableOutput("table")
    )

  })

I tried it with: Similar Problem but I can not resolve the problem. Without the box everything works fine.

Timothy_Goodman
  • 393
  • 1
  • 5
  • 18

1 Answers1

1

Never use reactive expressions inside a renderText function.

You have to wrap tagList around your two elements to return a SINGLE element (a list in your case).

Here is a reproduceable example.

library(shiny)
library(shinydashboardPlus)
library(dplyr)


# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Hide box"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            textInput("name", "Insert Number to filter cyl:")
        ),
        mainPanel(
           uiOutput("box")
        )
    )
)

server <- function(input, output) {

        resultdf <- reactive({
            mtcars %>%
                filter(cyl > input$name)
        })


        output$box <- renderUI({

            output$table <- renderDataTable({
                resultdf()
            })

            if(input$name == "") {
                 return(NULL)
            } else {
                return(
                    tagList(
                        boxPlus(
                            div(style = 'overflow-x: scroll;'), dataTableOutput("table")
                        )
                    )
                  )
                }
        })
}

# Run the application 
shinyApp(ui = ui, server = server)
DSGym
  • 2,807
  • 1
  • 6
  • 18