在edintedDTUI中水平滚动,在闪亮的仪表板中滚动editableDT

时间:2018-04-02 09:48:19

标签: r shiny editor shinydashboard modifier

我需要为app用户提供灵活性,以便他们可以编辑/修改表格。我使用以下代码 用户界面代码

tabItem(tabName = "manual_override",
            fluidRow(
              editableDTUI("table1")

服务器代码:

callModule(editableDT,"table1",data=reactive(bigtable),inputwidth=reactive(100))

但问题是 bigtable 有超过15列要显示且水平滚动没有显示

1 个答案:

答案 0 :(得分:0)

我尝试使用带有20 col的库(DT)。 如果这解决了你的问题。

ui.r

library(shiny)

library(DT)

shinyUI(

  fluidPage(
   navbarPage("Big file upload + Horizental Scrolling",
            tabPanel("Data Import",
               fluidRow(
                 fileInput("file","Upload Your CSV",multiple = FALSE),
                 column(6,
                        div(style = 'overflow-x: scroll',  DT::dataTableOutput('csv_data')))
               )      
            )
   )
  )
)

server.r

library(shiny)
shinyServer(function(input, output) {

  csv_data_fun<-eventReactive(input$file,{
    df<-read.csv(input$file$datapath,
                 header =TRUE)
     return(df)
  })

  output$csv_data<-DT::renderDataTable({
    DT::datatable(csv_data_fun(),rownames = FALSE)%>%formatStyle(columns=colnames(csv_data_fun()),background = 'white',color='black')
  })
})

输出屏幕 enter image description here

请检查您是否需要此

我已经完成了editDT,但这次是使用默认的mtcars数据集。 在UI部分添加了代码

div(style = 'overflow-x: scroll',editableDTUI("table1"))

新代码

library(shiny)
library(editData)

if (interactive()) {
  ui <- fluidPage(
    textInput("mydata","Enter data name",value="mtcars"),
    column(6, 
           div(style = 'overflow-x: scroll',editableDTUI("table1")
               )
    )
  )
  server <- function(input, output) {
    df=callModule(editableDT,"table1",dataname=reactive(input$mydata),inputwidth=reactive(170))

    output$test=renderPrint({
      str(df())
    })

  }
  shinyApp(ui, server)
}

如果这可以解决您的问题,请检查此时间。您可以根据自己的要求调整要更改的内容。 如果解决了您的问题,请接受答案。