I am developing shiny app where i need to have submenuitem in a menuitem with content in menuitem.
After research from stackoverflow, i found the below link, Show content for menuItem when menuSubItems exist in Shiny Dashboard
But the problem in above solution is whenever i click on submenuitem, the menuitem dropdown gets closed. So i need to click on menuitem again and then click again on menuitem to get the dropdown of submenuitem.
Please help me to solve this issue.
When i click on submenuitem, the dropdown should not automatically close.
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)
Please check the image for further clarification.
Thanks SJB