Me gustaría hacer plegables los elementos del menú en mi tablero brillante.
Encontré la publicación con una pregunta similar que había sido respondida hace algún tiempo:
solución al problema con 2 div-s
Sin embargo, la solución solo funciona con 2 div-s . ¿Es posible hacer algo similar con 3 elementos del menú ?
Código reproducible adjunto (publicado por Martin Schmelzer)
library(shiny) library(shinydashboard) server <- function(input, output) { } jsc <- ' $(document).ready(function () { $(".sidebar-menu").children("li").on("click", function() { $("#mult, #single").toggle(); }); }); ' ui <- dashboardPage( dashboardHeader(title = "Dashboard", titleWidth = 290), dashboardSidebar( width = 290, sidebarMenu( menuItem( "Multiple Incident Analysis", tabName = "dashboard", icon = icon("th")), div(id = "mult", splitLayout(cellWidths = c("44%", "31%", "25%"), dateInput("datefrom", "Date From:", format = "mm/dd/yyyy", Sys.Date()-5), textInput("datefrom_hour", "Hour", value = "12:00"), textInput("datefrom_noon","AM/PM", value = "AM")), splitLayout(cellWidths = c("44%", "31%", "25%"), dateInput("dateto", "Date To:", format = "mm/dd/yyyy"), textInput("dateto_hour", "Hour", value = "11:59"), textInput("dateto_noon","AM/PM", value = "PM"))), menuItem("Single Analysis", tabName = "widgets", icon = icon("th")), div(id = "single", style="display: none;", numericInput("tckt", "Ticket Number : ", 12345, width = 290)), submitButton("Submit", width = "290") )), dashboardBody( tags$head(tags$script(jsc)) )) shinyApp(ui, server)En shinydashboard , menuItem ya hace eso para tantos elementos de menú como quieras. Prueba esto
library(shiny) library(shinydashboard) server <- function(input, output) { } ui <- dashboardPage( dashboardHeader(title = "Dashboard", titleWidth = 290), dashboardSidebar( width = 290, sidebarMenu( menuItem( "Multiple Incident Analysis", tabName = "dashboard", icon = icon("th"), div(id = "mult", splitLayout(cellWidths = c("44%", "31%", "25%"), dateInput("datefrom", "Date From:", format = "mm/dd/yyyy", Sys.Date()-5), textInput("datefrom_hour", "Hour", value = "12:00"), textInput("datefrom_noon","AM/PM", value = "AM")))), menuItem( "Multiple Incident Analysis2", tabName = "dashboard2", icon = icon("th"), div(id = "mult2", splitLayout(cellWidths = c("44%", "31%", "25%"), dateInput("dateto", "Date To:", format = "mm/dd/yyyy"), textInput("dateto_hour", "Hour", value = "11:59"), textInput("dateto_noon","AM/PM", value = "PM")))), menuItem("Single Analysis", tabName = "widgets", icon = icon("th"), div(id = "single", numericInput("tckt", "Ticket Number : ", 12345, width = 290))), submitButton("Submit", width = "290") )), dashboardBody() ) shinyApp(ui, server)