R Shiny DataTable过滤器被切断

时间:2019-04-24 17:21:19

标签: r shiny shinydashboard

这是数据文件的链接,您可以将其转换为txt格式。 https://docs.google.com/document/d/1agR2wu82vBBv99DbmdXAQwyS9PF6nUUaKA1bGPH6eno/edit?usp=sharing

Here is the screenshot for the cutoff 当我将筛选器添加到闪亮的仪表板中的数据表时,筛选器的下拉框将被切除。是否可以解决此问题?(例如,对于“种类”列,过滤器下拉框未显示两个选项的整体外观,我需要以某种方式加宽下拉框。)可以在Rstudio中复制的代码:

library(shinydashboard)
library(ggplot2)
library(DT)


sidebar <- dashboardSidebar(
 sidebarMenu(
  menuItem("Summary", tabName = "summary"),
  menuItem("Analysis", tabName = "analysis")
 )
)


body <- dashboardBody(
   tabItems(
     tabItem(tabName = "summary",
     fluidRow(
     #column(width = 4,
     box(
      title = "Studies", width = 12, status = "danger", solidHeader = TRUE,

      div(style = 'overflow-y: scroll; max-height: 600px', DT::dataTableOutput('table'))
      #div(style = 'overflow-y: scroll; max-height: 300px', tableOutput('table'))
    )
    #)
  ),
  hr(),

  fluidRow(
    box(
      title = "Type of cancer", status = "warning", width = 6, plotOutput("hist1")
    ),

    box(
      title = "Data type", status = "warning", color="yellow", width = 6, plotOutput("DataType"))
  )
),
tabItem(tabName = "analysis", h2("Analysis and plots"))
)
)




ui <- dashboardPage(
   dashboardHeader(title = "Cancer research updates", titleWidth = 300),
   sidebar,
   body
)

server <- function(input, output) {
   #test.table <- data.frame(lapply(1:3, function(x) {1:20}))
   #names(test.table) <- paste0('This_is_a_very_long_name_', 1:3)
   pcdata <- read.csv("./data/ProstateCancerInput_Final.txt", sep = "\t", encoding = 'UTF-8')
   colnames(pcdata)[1] <- ''
   colnames(pcdata)[6] <- 'Data type'
   colnames(pcdata)[9] <- 'Type of cancer'
   pcdata$Link <- paste0("<a href ='",pcdata$Link,"'>","Link to data","</a>")
   output$table <- DT::renderDataTable({
   #test.table
   datatable(pcdata, rownames = FALSE, escape = FALSE,filter = 'top')
   })

   #windowsFonts(Arial=windowsFont("TT Arial")) 
 }

 shinyApp(ui = ui, server = server)

1 个答案:

答案 0 :(得分:1)

恭喜您提出了第一个SO问题:)我同意@divibisan的观点,即,一个可重现的示例(甚至是屏幕截图)将有所帮助。如果您不确定如何制作,请查看例如。这个article或这个video

根据您的描述,我认为您应该在表所在的div样式中添加“ overflow:visible”。Here是一些具有不同溢出属性值的图像,您可以使用他们here。如果不确定我的意思,请随时提出更多问题。

祝你好运!