如何在闪亮的 Jmeter 板侧边栏中的menuSubItem下包含输入小部件?

brccelvz  于 2023-02-14  发布在  其他
关注(0)|答案(1)|浏览(117)

如何在一个闪亮的应用程序的侧边栏中的menuSubItem下包含一个控件小部件?
这是我的审判

library(shiny)
library(shinyWidgets)
library(shinydashboard)

ui <- dashboardPage(
  
  ### Header -----
  
  dashboardHeader(title = "Example App"),
  
  ### Sidebar -----
  
  dashboardSidebar(
    
    sidebarMenu(
              
      menuItem(
        text = "A",
        tabName = "analytics",
        icon = icon("signal"),
        startExpanded = TRUE,
        
        menuSubItem(text = "a",
                    icon = NULL,
                    
                    pickerInput(
                      inputId = "Id086",
                      label = "Placeholder", 
                      choices = c("a", "b", "c", "d"),
                      options = list(
                        title = "This is a placeholder")
                    )
                    ),
        
        
        menuSubItem(text = "b",
                    icon = NULL)
        
        
      )
      
    )
    
  ),
  
  dashboardBody(
    
  )
  
)

## Server-function -----

server <- function(input, output) {
  
  
}

# Run the application 
shinyApp(ui = ui, server = server)

然而,所需的输入没有出现在应用程序中。我设法将输入小部件包含在任何菜单项下,但未能使其出现在menuSubItems下。

yhived7q

yhived7q1#

menuSubItem用于在主体中导航tabItem-这就是它们不能有子元素的原因。
您可以使用嵌套的menuItem在侧边栏中放置额外的输入(请参见下面的示例),这些输入在有子项/无子项时的“行为”不同。
menuItem是childfull时,它接受参数expandedNamestartExpanded
当一个menuItem没有子节点时,它接受参数tabNameselected
一个menuSubItem总是没有子代的。

library(shiny)
library(shinyWidgets)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Example App"),
  dashboardSidebar(sidebarMenu(
    menuItem(
      text = "A",
      # tabName = "analytics", # childfull menuItems ignore the tabName parameter they use expandedName instead
      icon = icon("signal"),
      startExpanded = TRUE,
      menuItem(
        text = "a",
        menuSubItem(
          text = "a1",
          tabName = "tab_a1",
          icon = NULL
        ),
        pickerInput(
          inputId = "Id086",
          label = "Placeholder",
          choices = c("a", "b", "c", "d"),
          options = list(title = "This is a placeholder")
        ),
        icon = NULL,
        startExpanded = TRUE
      ),
      menuSubItem(
        text = "b",
        tabName = "tab_b",
        icon = NULL
      )
    )
  )),
  dashboardBody(tabItems(
    tabItem(tabName = "tab_a1",
            h2("tab_a1 content")),
    tabItem(tabName = "tab_b",
            h2("tab_b content"))
  ))
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

在这里你可以找到一个相关的问题。
然而,我个人建议使用shinydashboardPlus的right sidebar作为输入,只使用左侧栏作为导航。

相关问题