updatebs4TabSetPanel: Update a bs4TabSetPanel

Description Usage Arguments Examples

Description

Update a bs4TabSetPanel

Alias to updatebs4TabSetPanel See updatebs4TabSetPanel for full details

Usage

1
2
3
4
5
updatebs4TabSetPanel(session, inputId, selected = NULL)

updatebs4ControlbarMenu(session, inputId, selected = NULL)

updateTabsetPanel(session, inputId, selected = NULL)

Arguments

session

shiny session.

inputId

bs4TabSetPanel unique id.

selected

the tab to be selected.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
if (interactive()) {
 library(shiny)
 library(bs4Dash)
 
 
 shinyApp(
  ui = bs4DashPage(
   sidebar_collapsed = FALSE,
   controlbar_collapsed = TRUE,
   enable_preloader = FALSE,
   loading_duration =  2,
   navbar = bs4DashNavbar(skin = "dark"),
   body = bs4DashBody(
     bs4TabSetPanel(
       id = "tabset1",
       side = "left",
       bs4TabPanel(
         tabName = "Tab 1", 
         active = FALSE,
         numericInput("val", "Value:", 10, min = 1, max = 100),
         verbatimTextOutput("value")
       ),
       bs4TabPanel(
         tabName = "Tab 2", 
         active = TRUE,
         "Content 2"
       ),
       bs4TabPanel(
         tabName = "Tab 3", 
         active = FALSE,
         checkboxGroupInput(
           inline = TRUE,
           "variable", "Variables to show:",
           c("Cylinders" = "cyl",
             "Transmission" = "am",
             "Gears" = "gear")
         ),
         tableOutput("data")
       )
     ),
     uiOutput("tabSetPanel2")
   ),
   sidebar = bs4DashSidebar(
     skin = "light",
     sliderInput(
       inputId = "controller",
       label = "Update the first tabset",
       min = 1,
       max = 3,
       value = 2
     ),
     br(),
     sliderInput(
       inputId = "controller2",
       label = "Update the second tabset",
       min = 1,
       max = 3,
       value = 3
     )
   ),
   controlbar = bs4DashControlbar(skin = "light"),
   footer = bs4DashFooter()
 ),
 server = function(input, output, session) {
 
   output$tabSetPanel2 <- renderUI({
    bs4TabSetPanel(
      id = "tabset2",
      side = "left",
      bs4TabPanel(
        tabName = "Tab 1", 
        active = FALSE,
        p("Tab 1 ")
      ),
      bs4TabPanel(
        tabName = "Tab 2", 
        active = FALSE,
        p("Tab 2")
      ),
      bs4TabPanel(
        tabName = "Tab 3", 
        active = FALSE,
        p("Tab 3")
      )
    )
   })
   
   # update tabset1
   observeEvent(input$controller, {
     updatebs4TabSetPanel(
       session, 
       inputId = "tabset1", 
       selected = paste("Tab", input$controller)
     )
   }, ignoreInit = TRUE)
   
   # update tabset 2
   observeEvent(input$controller2, {
     updatebs4TabSetPanel(
       session, 
       inputId = "tabset2", 
       selected = paste("Tab", input$controller2)
     )
   }, ignoreInit = TRUE)
   
   output$distPlot <- renderPlot({
     hist(rnorm(input$obs))
   })
   
   output$data <- renderTable({
     mtcars[, c("mpg", input$variable), drop = FALSE]
   }, rownames = TRUE)
   
   output$txt <- renderText({
     paste("You chose", input$rb)
   })
   
   output$value <- renderText({ input$val })
   
  }
 )
}

RX-PBB/bs4Mash documentation built on April 11, 2020, 12:15 a.m.