Factor dropdown filter on DT::datatable gets cut off

766 views
Skip to first unread message

Ajinkya Kale

unread,
Feb 2, 2016, 8:08:56 PM2/2/16
to Shiny - Web Framework for R

Hi,

Is it just me or is it a bug that if i have a factor column and I add filter with DT, the dropdown get cut-off in shiny dashboard.

I am using mtcars as an example and I make cyl as a factor. (the numeric slider filter works fine, but the factor filter dont). Here is the code and the screen shot. 

## app.R ##
library(shinydashboard)
library(dplyr)


mtcars$cyl <- as.factor(mtcars$cyl)

ui <- dashboardPage(
  dashboardHeader(title = "Simple Dashboard"),
  ## Sidebar content
  dashboardSidebar(sidebarMenu(
    menuItem(
      "Dashboard", tabName = "dashboard", icon = icon("dashboard")
    ),
    menuItem("Widgets", tabName = "widgets", icon = icon("th"))
  )),
  ## Body content
  dashboardBody(tabItems(
    # First tab content
    tabItem(tabName = "dashboard",
            fluidRow(
              box(plotOutput("plot1", height = 250)),
              
              box(
                title = "Controls",
                sliderInput("slider", "Number of observations:", 1, 100, 50)
              )
            )),
    
    # Second tab content
    tabItem(tabName = "widgets",
            fluidRow(DT::dataTableOutput('items_dt')))
  ))
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)
  
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
  
  output$items_dt = DT::renderDataTable(
    mtcars,
    filter = 'bottom',
    options = list(scrollX = TRUE)
  )
}

shinyApp(ui, server)


 <- cyl filter dropdown cutoff


 <- numeric slider filter works fine



Ajinkya Kale

unread,
Feb 2, 2016, 8:14:56 PM2/2/16
to Shiny - Web Framework for R
Maybe its an issue only when you render a DT in dashboards ? 
I tried same code in regular shiny apps and it works fine. 

Yihui Xie

unread,
Feb 3, 2016, 11:43:43 PM2/3/16
to Ajinkya Kale, Shiny - Web Framework for R
Yeah, it might have something to do with shinydashboards. For the
record, same issue logged at https://github.com/rstudio/DT/issues/230


Regards,
Yihui
>> <- cyl filter dropdown cutoff
>>
>>
>> <- numeric slider filter works fine
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/4bd74aa4-9b8a-4f72-9b8c-da5003214c2b%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Mingjie Wang

unread,
Nov 9, 2016, 12:25:32 PM11/9/16
to Shiny - Web Framework for R, kalea...@gmail.com

Hi Yihui,

I am also experiencing the same problem. Is there a good solution for this? Does it help by using DT 0.2?

Thanks,
Mingjie

Yihui Xie

unread,
Nov 9, 2016, 12:41:18 PM11/9/16
to Mingjie Wang, Shiny - Web Framework for R, Ajinkya Kale
Yes, please try the newer version if you are still using DT 0.1.

Regards,
Yihui
> https://groups.google.com/d/msgid/shiny-discuss/9eb75432-6fa1-47e4-829b-4fd4d1436cbf%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages