2017-08-17 3 views
0

Gibt es eine Möglichkeit shinydashboard Menü permanent erweitert wie auf Bild zu setzen unter:dauerhaft erweitert Akkordeon in shinydashboard

enter image description here

Ich weiß, Akkordeon-Menüs wie folgt verhalten (ich meine nur kann man auf die erweitert werden (gleiche Zeit) aufgrund der Dokumentation, aber vielleicht gibt es einen Trick, um dies zu tun oder eine Alternative in meiner glänzenden App zu implementieren?

Hier Code:

library(shiny) 
library(shinydashboard) 

header <- dashboardHeader() 

    sidebar <- dashboardSidebar(
    sidebarMenu(
     # Setting id makes input$tabs give the tabName of currently-selected tab 
     id = "tabs", 
     menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 
     menuItem("Widgets", icon = icon("th"), tabName = "widgets", 
       menuSubItem("Sub-item 1", tabName = "subitem1"), 
       menuSubItem("Sub-item 2", tabName = "subitem2"), 
       startExpanded = TRUE), 
     menuItem("Charts", icon = icon("bar-chart-o"), 
       menuSubItem("Sub-item 3", tabName = "subitem3"), 
       menuSubItem("Sub-item 4", tabName = "subitem4"), 
       startExpanded = TRUE 
    ) 
    ) 
) 

    body <- dashboardBody(
    tabItems(
     tabItem("dashboard", 
       div(p("Dashboard tab content")) 
    ), 
     tabItem("widgets", 
       "Widgets tab content" 
    ), 
     tabItem("subitem1", 
       "Sub-item 1 tab content" 
    ), 
     tabItem("subitem2", 
       "Sub-item 2 tab content" 
    ) 
    ) 
) 

    shinyApp(
    ui = dashboardPage(header, sidebar, body), 
    server = function(input, output) { } 
) 

Antwort

0

Ok, das sehr hacky ist, und es kann eine bessere Art und Weise, dies zu tun, aber Sie können CSS-Styling verwenden, um die Links „unter“ dem anderen Inhalt zu bewegen, so dass sie kann nicht mit dem Z-Index angeklickt werden. Leider sieht es so aus, als müssten Sie jeden Menüeintrag manuell codieren und auf seinen href verweisen. Siehe dieses Beispiel:

library(shiny) 
library(shinydashboard) 

header <- dashboardHeader() 

sidebar <- dashboardSidebar(
    sidebarMenu(
    tags$head(tags$style(HTML(' 
     a[href="#shiny-tab-widgets"] { 
      z-index: -99999; 
     } 
     a[href="#"] { 
      z-index: -99999; 
     } 
     '))), 

    # Setting id makes input$tabs give the tabName of currently-selected tab 
    id = "tabs", 
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), 
    menuItem("Widgets", icon = icon("th"), tabName = "widgets", 
      menuSubItem("Sub-item 1", tabName = "subitem1"), 
      menuSubItem("Sub-item 2", tabName = "subitem2"), 
      startExpanded = TRUE), 
    menuItem("Charts", icon = icon("bar-chart-o"), 
      menuSubItem("Sub-item 3", tabName = "subitem3"), 
      menuSubItem("Sub-item 4", tabName = "subitem4"), 
      startExpanded = TRUE 
    ) 
) 
) 

body <- dashboardBody(

    tabItems(
    tabItem("dashboard", 
      div(p("Dashboard tab content")) 
    ), 
    tabItem("widgets", 
      "Widgets tab content" 
    ), 
    tabItem("subitem1", 
      "Sub-item 1 tab content" 
    ), 
    tabItem("subitem2", 
      "Sub-item 2 tab content" 
    ) 
) 
) 

shinyApp(
    ui = dashboardPage(header, sidebar, body), 
    server = function(input, output) { } 
)