我有一个用tabsetPanel填充的dashboardBody。我正在寻找的是一种为每个tabPanel提供自己的sidebarMenu
的方法在我的代码中,选择选项卡时,仅正文中的文本会更改。如何以更新sidebarMenu的方式扩展此代码?
我在stackoverflow上找到了几篇文章(stackoverflow.com/questions/36742932/r-shinydashboard-dynamic-menu-selection),但据我所知,它们只是相反地起作用。单击侧栏菜单会导致主体发生变化。
library(shiny)
library(shinydashboard)
library(shinyWidgets)
header <- dashboardHeader(disable = TRUE)
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Hele Proces", tabname = "Totaal"),
menuItem("Inhuur", tabname = "Inhuur")
)
)
MainBox <- fluidRow(
navbarPage(
tabsetPanel(id = "Tabs",
tabPanel("Quick Facts", textOutput('text_out_1')),
tabPanel("Pre-audit", textOutput('text_out_2')),
tabPanel("Filter(s)"
)
)
)
)
body <- dashboardBody(titlePanel("PromView"), MainBox)
ui <- dashboardPage(title = "PromView",
skin = "blue",
header,
sidebar,
body
)
server <- function(input, output, session) {
output$text_out_1 <- renderText({
paste("You have selected", input$Tabs)
})
output$text_out_2 <- renderText({
paste("You have selected", input$Tabs)
})
}