r - How to add the same inputs into two tabItems in shinydashboard? -


i using shinydashboard create interface of shiny app. want 1 input appear in 2 tabmenu. in example below, want textinput i_test appears in menu menu1 , menu2.

how should implement it? suggestions.

library(shiny) library(shinydashboard)  # side bar boardy sidebar <- dashboardsidebar(     sidebarmenu(         id = 'menu_tabs'         , menuitem('menu1', tabname = 'menu1')         , menuitem('menu2', tabname = 'menu2')         , menuitem('menu3', tabname = 'menu3')     ) )  # body board body <- dashboardbody(     tabitems(         tabitem(             tabname = 'menu1',             textinput('i_test', 'test')         ),         tabitem(             tabname = 'menu2'         )     ) )  # shiny ui ui <- dashboardpage(     title = 'test',     dashboardheader(),     sidebar,     body )  server <- function(input, output, session) { }  shinyapp(ui, server) 

it seems shiny renders 2 distinct elements, if try build same element second time.

thats why come solution makes 2 text iputs same.

check code:

library(shiny) library(shinydashboard)  # side bar boardy sidebar <- dashboardsidebar(   sidebarmenu(     id = 'menu_tabs'     , menuitem('menu1', tabname = 'menu1')     , menuitem('menu2', tabname = 'menu2')     , menuitem('menu3', tabname = 'menu3')   ) )  # body board body <- dashboardbody(   tabitems(     tabitem(       tabname = 'menu1',       textinput('i_test_1', 'test')     ),     tabitem(       tabname = 'menu2',       textinput('i_test_2', 'test')     ),     tabitem(       tabname = 'menu3'     )   ) )  # shiny ui ui <- dashboardpage(   title = 'test',   dashboardheader(),   sidebar,   body )  server <- function(input, output, session) {    observe({     text1 <- input$i_test_1             updatetextinput(session, 'i_test_2', value = text1)   })   observe({     text2 <- input$i_test_2             updatetextinput(session, 'i_test_1', value = text2)   })  }  shinyapp(ui, server) 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -