我想将Shinydashboard输入字段显示为一种menuSubItem,但是我发现很难编写解决方案。
你有解决方法吗?
ui.R
library(shiny)
library(shinydashboard)
library(leaflet)
source("R/load_metadata.R", chdir=TRUE)
# Header of the dashboard
header <- dashboardHeader(
title = "x",
titleWidth = 350,
dropdownMenuOutput("task_menu")
)
# Sidebar of the dashboard
sidebar <- dashboardSidebar(
sidebarMenu(
id = "menu_tabs",
menuItem("Household Penetration", tabName = "menutab1", icon = icon("percent")),
selectInput("storeInput", label = "Store",
choices = STOREFILTER$STORE_NAME,
selected = STOREFILTER$STORE_NAME[1]),
actionButton("Button", "Filter Map"),
menuItem("Sales", tabName = "menutab2", icon = icon("euro"))
)
)
# Body of the dashboard
body <- dashboardBody(
tabItems(
tabItem(
tabName = "menutab1",
tags$style(type = "text/css", "#mymap {height: calc(100vh - 80px) !important;}"),
leafletOutput("mymap")),
tabItem(
tabName = "menutab2",
tags$style(type = "text/css", "#mymap {height: calc(100vh - 80px) !important;}"),
h2("Dashboard tab content")
)
)
)
# Shiny UI
ui <- dashboardPage(
header,
sidebar,
body,
tags$head(
tags$style(HTML(type='text/css', "#Button { width:40%; margin-left: 30%; margin-right: 30%; background-color: #3C8DBC; color: black; font-weight: bold; border: 0px}")))
)
答案 0 :(得分:0)
根据所选菜单,您可以使用conditionalPanel
显示/隐藏输入字段:
conditionalPanel(
condition = "input.menu_tabs == 'menutab1'",
selectInput("storeInput", label = "Store",
choices = STOREFILTER$STORE_NAME,
selected = STOREFILTER$STORE_NAME[1]),
actionButton("Button", "Filter Map")
)