Horizontal scroll bar in shiny in inactive state

2019-07-24 20:42发布

问题:

In shiny app numeric input widgets are created dynamically in row and column which i want to put in a box with horizontal scroll bar if more than 2 columns are selected.

Scroll bars appeared both at top and bottom but in inactive state.I have tried with auto option in scroll but not working. Please help.

ui.R

library(shiny)
library(shinydashboard)

ui <- shinyUI(fluidPage(
titlePanel(title = "scroll bar in inactive state"), 
sidebarLayout(

sidebarPanel(numericInput("rows","Input No. of rows",value = 5,min=1),
             br(),
             numericInput("col","Input No. of cols",value = 1,min=1)),


mainPanel(box(title = "what if", 
                              width = 7,
                              style = "overflow-x: scroll", uiOutput("plo")))
)))

server.R

 server <- function(input,output){

 # creating input widgets dynamically
 output$plo <- renderUI({
 z <- input$col

lapply(seq(input$col), function(j){
  column(width=5,
         lapply(seq(input$rows),function(i){
           numericInput(inputId = paste0("range",paste0(i,j)),label =  
     j,value = paste0(i,j))  
         })
  )
 })
})
}    

回答1:

Please try using

div(style = 'overflow-x: scroll', uiOutput("plo")) instead of style = "overflow-x: scroll", uiOutput("plo")