r - shinydashboard does not work with uiOutput -
i setup ui in server.r more control, shinydashboard not work when defined in server.r. use method navbarpage without problems.
this code works
library(shiny) library(shinydashboard) ui <- dashboardpage( dashboardheader( ), dashboardsidebar(), dashboardbody() ) server <- shinyserver(function(input, output) { }) runapp(list(ui= ui, server = server))
but 1 show empty page
ui <- uioutput('dash') server <- shinyserver(function(input, output) { output$dash <- renderui({ dashboardpage(dashboardheader( ), dashboardsidebar(), dashboardbody() ) }) }) runapp(list(ui= ui, server = server))
this example using navbarpage, works fine
ui <- uioutput('nav') server <- shinyserver(function(input, output) { output$nav <- renderui({ navbarpage("app title", tabpanel("tab 1"), tabpanel("tab 2") ) }) }) runapp(list(ui= ui, server = server))
i don't think can use uioutput
create dashboard. i'm assuming goal create dynamic dashboard. need define header, body , side bar in ui , use functions such rendermenu
on server create it. here example create dashboard ui defined in server.
ui <- dashboardpage( dashboardheader(title = "my page"), dashboardsidebar(sidebarmenuoutput("sidebar_menu_ui")), dashboardbody( uioutput("body_ui"), uioutput("test_ui") ) ) server <- shinyserver(function(input, output, session) { output$sidebar_menu_ui <- rendermenu({ sidebarmenu(id = "sidebar_menu", menuitem("menu 1", tabname="menu1_tab", icon = icon("calendar")), menuitem("menu 2", tabname="menu2_tab", icon = icon("database")) ) }) output$test_ui <- renderui ({ tabitems( tabitem(tabname = "menu1_tab", uioutput("menu1_ui")), tabitem(tabname = "menu2_tab", uioutput("menu2_ui")) ) }) output$body_ui <- renderui ({ p("default content in body outsite sidebar menus.") }) output$menu1_ui <- renderui ({ box("menu 1 content") }) output$menu2_ui <- renderui ({ box("menu 2 content") }) }) runapp(list(ui= ui, server = server))
in example, menu sidebar not selected default , content of body_ui
visible time. if want dashboard starts on specific menu, put sidebarmenu
in ui. can delete body_ui
.
Comments
Post a Comment