在菜单项中包含内容的子菜单 - 闪亮的仪表板

时间:2018-06-15 05:44:15

标签: r shiny

我正在开发闪亮的应用程序,我需要在menuitem中设置submenuitem,其中包含menuitem中的内容。

经过stackoverflow的研究后,我找到了以下链接, Show content for menuItem when menuSubItems exist in Shiny Dashboard

但上述解决方案中的问题是每当我点击子菜单时,菜单项下拉菜单都会关闭。所以我需要再次点击menuitem,然后再次点击menuitem以获得子菜单的下拉列表。

请帮我解决这个问题。

当我点击子菜单时,下拉菜单不应自动关闭。

library(shiny)
library(shinydashboard)

convertMenuItem <- function(mi,tabName) {
  mi$children[[1]]$attribs['data-toggle']="tab"
  mi$children[[1]]$attribs['data-value'] = tabName
  if(length(mi$attribs$class)>0 && mi$attribs$class=="treeview"){
    mi$attribs$class=NULL
  }
  mi
}

ui <- dashboardPage(skin = "black", 

                dashboardHeader(
                  title = "test"), 
                dashboardSidebar(
                  sidebarMenu(id = "tabs",
                              convertMenuItem(menuItem("Data Scorecard", tabName = "scd",
                                                       menuSubItem("C1", tabName = "comp",icon = icon("angle-double-right")),
                                                       menuSubItem("C2", tabName = "consist",icon = icon("angle-double-right")),
                                                       menuSubItem("C3", tabName = "confirm",icon = icon("angle-double-right")),
                                                       menuSubItem("c4", tabName = "dupli",icon = icon("angle-double-right")),
                                                       menuSubItem("c5", tabName = "inte",icon = icon("angle-double-right")),
                                                       menuSubItem("c6", tabName = "accu",icon = icon("angle-double-right")),
                                                       menuSubItem("c7", tabName = "age",icon = icon("angle-double-right"))),"scd"))),


                dashboardBody(
                              tabItems(
                        tabItem(tabName = "scd", 
                                fluidRow(h4("scd"))),

                        tabItem(tabName = "comp",
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "consist",
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "confirm",
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "dupli",
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "inte", 
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "accu",
                                fluidRow(h4("c1"))),
                        tabItem(tabName = "age",
                                fluidRow(h4("c1")))
                )))

server <- function(input, output, session) { 
  }
shinyApp(ui, server)

请检查图像以获得进一步说明。

menuitem dropdown dropdown closes on submenuitem click

由于 SJB

1 个答案:

答案 0 :(得分:0)

对菜单项()使用[37, 23, 31, 41, 17, 71, 23, 31, 17, 71, 19, 37] 参数。在整个会话过程中,菜单应保持打开状态。

startExpanded = TRUE