0

I am trying to put dashboard inside action action button named load scenario.Here dashboard is visible when load scenario button is pressed twice.But i want to show the dashboard page as soon as load scenario button is pressed(not two time).Here is my sample code.

 library("shiny")
 library("shinydashboard")
 ui <- fluidPage(


  actionButton("create_scenario", "Create Scenario"),
  actionButton("load_scenario","load scenario"),
 uiOutput("input"),
  uiOutput("inputs")
 )

 server <- function(input, output,session) {

  observeEvent(input$create_scenario,{

    output$input <- renderUI({
     textInput("txtInput","Enter Scenario Name","Enter name as scenario         
              (number of senario created +1)")
    })


   })

  observeEvent(input$load_scenario,{

    output$inputs <- renderUI({
     # textInput("txtInput","Enter Scenario Name","Enter name as scenario  
     #(number of senario created +1)")
      dashboardPage(
       dashboardHeader(title = "Basic dashboard"),
       dashboardSidebar(),
      dashboardBody(
      # Boxes need to be put in a row (or column)
      fluidRow(
        box(plotOutput("plot1", height = 250)),

        box(
          title = "Controls",
          sliderInput("slider", "Number of observations:", 1, 100, 50)
        ))))


} )

histdata <- rnorm(500)
output$plot1 <- renderPlot({
  data <- histdata[seq_len(input$slider)]
  hist(data)
    })


  })
}
shinyApp(ui, server)

Please ignore the create scenario button.I have used renderUI function to do this task.If any other approach by which i can put dashboard inside action button please tell me

  • Please don't [repost](https://stackoverflow.com/questions/56118973/when-dashboard-is-present-inside-action-button-it-is-showing-result-when-button) your questions. I provided an answer [here](https://stackoverflow.com/a/56208618/9841389) – ismirsehregal May 19 '19 at 14:13
  • Possible duplicate of [When dashboard is present inside action-button it is showing result when button is pressed twice](https://stackoverflow.com/questions/56118973/when-dashboard-is-present-inside-action-button-it-is-showing-result-when-button) – ismirsehregal May 20 '19 at 12:54

0 Answers0