Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not see my second tabitem after clicking action button #386

Open
sgr308 opened this issue Jul 21, 2022 · 1 comment
Open

can not see my second tabitem after clicking action button #386

sgr308 opened this issue Jul 21, 2022 · 1 comment

Comments

@sgr308
Copy link

sgr308 commented Jul 21, 2022

Hi
I am learning Shiny to develop an App.

I have two tabItems in sidebar where first one is simple home page and in another, user has to upload the .txt file.

After click on submit button I want to see the uploaded file contents but I can not see the second tabitem contents in my dashboardBody after clicking on action button.

Can someone please let me know if I am missing something in this code??

The code is here:

# Upload library ----
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "First App"),
  dashboardSidebar(
    sidebarMenu(
      id = "tabs",
      menuItem("About", tabName = "first", icon = icon("home")),
      menuItem("Upload Data", tabName = "second", icon = icon("home"),
               fileInput("file1", "Upload a .txt file",
                         accept = c("text/csv", "text/comma-separated-values,text/plain",".csv",
                                    options(shiny.maxRequestSize=900*1024^2))),
      actionButton('submit', 'Submit!!'))
    )
  ),
  dashboardBody(
    tabItems(
    tabItem(tabName = "first",
            h3("App Ver 0.1.0")
            ),
    tabItem(tabName = "second",
            h2("Results Table"),
            tableOutput("contents")
            )
          )
  )
)
server <- function(input, output, session) {
  observeEvent(input$submit, {
    updateTabItems(session, "tabs", selected = "first" )
  })
  output$contents <- renderTable(rownames = TRUE,{
    if (is.null(input$file1)) return(NULL)
    head(read.csv(input$file1$datapath))
  })
}
shinyApp(ui, server)

@ismirsehregal
Copy link

For future readers: here you can find a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants