r - Factor dropdown filter in DT::datatable in shiny dashboards not working -
is me or bug if have factor column , add filter dt, dropdown cut-off in shiny dashboard.
i using mtcars example , make cyl factor. (the numeric slider filter works fine, factor filter dont). here code , 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)
i've had better luck dropdowns not doing scrollx or scrolly - , putting filters @ top.
b^(
Comments
Post a Comment