Conditional display in box based on tabbox selected in shinydashboard

448 views
Skip to first unread message

Tomas Hujo

unread,
Jun 30, 2016, 10:49:41 AM6/30/16
to Shiny - Web Framework for R



I use shiny with shinydashboard. I have one tabbox with two tabPanels. Then there is another box which should display either textOutput("a") if tab1 in tabbox is selected or textOutput("b") if tab2 is selected.

I provide whole code for reproducibility but watch out for comments which show where the important part is.



 library(shiny) library(shinydashboard) ui<-dashboardPage(skin = "red", dashboardHeader(title="lalala",titleWidth = 450), sidebar <-dashboardSidebar(width=400, sidebarMenu( menuItem(text = strong("First tab"),tabName="first",icon = icon("dashboard")) )), body <- dashboardBody( fluidRow( tabBox( title = "First tabBox", id = "tabset1", height = "250px", ############## based on which of this tab is selected tabPanel("Tab1", "First tab content"), tabPanel("Tab2", "Tab content 2") ), box( title = "Selection criteria for chart", height = "700px",width = 4, solidHeader = TRUE,status="danger", ############## I want in this box to display either textouput "a" or "b" textOutput("a") ) ))) server<-function(input,output){ output$a<-renderText( a<-"ahoj" ) output$b<-renderText( b<-"cau" ) }

Tomas Hujo

unread,
Jun 30, 2016, 10:50:38 AM6/30/16
to Shiny - Web Framework for R
Or here better formatted http://stackoverflow.com/questions/38125385/conditional-display-in-box-based-on-tabbox-selected-in-shinydashboard

Dňa štvrtok, 30. júna 2016 16:49:41 UTC+2 Tomas Hujo napísal(-a):
Reply all
Reply to author
Forward
0 new messages