Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shinydashboard: Is it not possible to have nested menu sub items? Can't make it work

I am using a shinydashboard, and have a need to build two-level nested sub menus. I am trying this and won't work:

library(shinydashboard)
sidebar <- dashboardSidebar(
  sidebarMenu(id = 'sidebarmenu',
              menuItem('x', tabName = 'x', icon = icon('line-chart')),
              menuItem('y', tabName = 'y',
                       icon = icon('line-chart'),
                       menuSubItem('a',
                                   tabName = 'a',
                                   icon = icon('line-chart')),
                       menuSubItem('b',
                                   tabName = 'b',
                                   icon = icon('line-chart'),
                                   menuSubItem('l',
                                               tabName = 'l',
                                               icon = icon('line-chart')),
                                   menuSubItem('m',
                                               tabName = 'm',
                                               icon = icon('line-chart'))),
                       menuSubItem('c',
                                   tabName = 'c',
                                   icon = icon('line-chart'))
              )))

Gives me error:

Error in menuSubItem("b", tabName = "b", icon = icon("line-chart"), menuSubItem("l",  : 
  Can't specify both href and tabName

Is it possible to build two-level nesting? Of course, removing l and m sub menus above works just fine (with one level sub menus).

like image 687
Gopala Avatar asked Jun 02 '16 16:06

Gopala


1 Answers

It works if you only use menuSubItem as the lowest level, and call the others menuItem. Will that work for your purposes?

sidebar <- dashboardSidebar(
sidebarMenu(id = 'sidebarmenu',
            menuItem('x', tabName = 'x', icon = icon('line-chart')),
            menuItem('y', tabName = 'y',
                     icon = icon('line-chart'),
                     menuItem('a',
                                 tabName = 'a',
                                 icon = icon('line-chart')),
                     menuItem('b',
                                 tabName = 'b',
                                 icon = icon('line-chart'),
                                 menuSubItem('l',
                                             tabName = 'l',
                                             icon = icon('line-chart')),
                                 menuSubItem('m',
                                             tabName = 'm',
                                             icon = icon('line-chart'))),
                     menuItem('c',
                                 tabName = 'c',
                                 icon = icon('line-chart'))
            )))
like image 185
Bryan Goggin Avatar answered Oct 08 '22 09:10

Bryan Goggin